Skip to content

Commit b1dbfcb

Browse files
author
JDC
committed
Add test remove tag filter
1 parent d54c3ee commit b1dbfcb

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎tests/test_remove.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,29 @@ def test_remove_domain(tmp_path, process, disable_extractors_dict):
7070

7171
assert count == 0
7272

73+
74+
def test_remove_tag(tmp_path, process, disable_extractors_dict):
75+
subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/example.com.html'], capture_output=True, env=disable_extractors_dict)
76+
subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/iana.org.html'], capture_output=True, env=disable_extractors_dict)
77+
assert list((tmp_path / "archive").iterdir()) != []
78+
79+
conn = sqlite3.connect("index.sqlite3")
80+
c = conn.cursor()
81+
c.execute("INSERT INTO core_tag (id, name, slug) VALUES (2, 'test-tag', 'test-tag')")
82+
snapshot_ids = c.execute("SELECT id from core_snapshot")
83+
c.executemany('INSERT INTO core_snapshot_tags (snapshot_id, tag_id) VALUES (?, 2)', list(snapshot_ids))
84+
conn.commit()
85+
86+
remove_process = subprocess.run(['archivebox', 'remove', '--filter-type=tag', 'test-tag', '--yes', '--delete'], capture_output=True)
87+
88+
assert len(list((tmp_path / "archive").iterdir())) == 0
89+
90+
count = c.execute("SELECT COUNT() from core_snapshot").fetchone()[0]
91+
conn.commit()
92+
conn.close()
93+
94+
assert count == 0
95+
7396
def test_remove_before(tmp_path, process, disable_extractors_dict):
7497
subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/example.com.html'], capture_output=True, env=disable_extractors_dict)
7598
subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/iana.org.html'], capture_output=True, env=disable_extractors_dict)

0 commit comments

Comments
 (0)