Browse Source

fix tests

Nick Sweeting 4 năm trước cách đây
mục cha
commit
46a4197514
3 tập tin đã thay đổi với 7 bổ sung7 xóa
  1. 1 1
      archivebox/index/sql.py
  2. 3 3
      tests/test_init.py
  3. 3 3
      tests/test_remove.py

+ 1 - 1
archivebox/index/sql.py

@@ -61,7 +61,7 @@ def write_link_to_sql_index(link: Link):
                     }
                 )
             else:
-                result, _ = ArchiveResult.objects.create_or_update(
+                result, _ = ArchiveResult.objects.update_or_create(
                     snapshot_id=snapshot.id,
                     extractor=extractor,
                     start_ts=parse_date(entry.start_ts),

+ 3 - 3
tests/test_init.py

@@ -12,12 +12,12 @@ from archivebox.config import OUTPUT_PERMISSIONS
 from .fixtures import *
 
 def test_init(tmp_path, process):
-    assert "Initializing a new ArchiveBox collection in this folder..." in process.stdout.decode("utf-8")
+    assert "Initializing a new ArchiveBox" in process.stdout.decode("utf-8")
     
 def test_update(tmp_path, process):
     os.chdir(tmp_path)
     update_process = subprocess.run(['archivebox', 'init'], capture_output=True)
-    assert "Updating existing ArchiveBox collection in this folder" in update_process.stdout.decode("utf-8")
+    assert "updating existing ArchiveBox" in update_process.stdout.decode("utf-8")
 
 def test_add_link(tmp_path, process, disable_extractors_dict):
     disable_extractors_dict.update({"USE_WGET": "true"})
@@ -173,4 +173,4 @@ def test_tags_migration(tmp_path, disable_extractors_dict):
         snapshot_id = tag["id"]
         tag_name = tag["name"]
         # Check each tag migrated is in the previous field
-        assert tag_name in snapshots_dict[snapshot_id]
+        assert tag_name in snapshots_dict[snapshot_id]

+ 3 - 3
tests/test_remove.py

@@ -100,7 +100,7 @@ def test_remove_before(tmp_path, process, disable_extractors_dict):
 
     conn = sqlite3.connect("index.sqlite3")
     c = conn.cursor()
-    timestamp = c.execute("SELECT timestamp FROM core_snapshot ORDER BY timestamp ASC").fetchall()
+    timestamp = c.execute("SELECT timestamp FROM core_snapshot ORDER BY timestamp DSC").fetchall()
     conn.commit()
     conn.close()
 
@@ -118,7 +118,7 @@ def test_remove_after(tmp_path, process, disable_extractors_dict):
 
     conn = sqlite3.connect("index.sqlite3")
     c = conn.cursor()
-    timestamp = c.execute("SELECT timestamp FROM core_snapshot ORDER BY timestamp ASC").fetchall()
+    timestamp = c.execute("SELECT timestamp FROM core_snapshot ORDER BY timestamp DSC").fetchall()
     conn.commit()
     conn.close()
 
@@ -127,4 +127,4 @@ def test_remove_after(tmp_path, process, disable_extractors_dict):
     subprocess.run(['archivebox', 'remove', '--filter-type=regex', '.*', '--yes', '--delete', '--after', str(after[1])], capture_output=True)
 
     assert (tmp_path / "archive" / timestamp[1][0]).exists()
-    assert not (tmp_path / "archive" / timestamp[0][0]).exists()
+    assert not (tmp_path / "archive" / timestamp[0][0]).exists()