tests.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. __package__ = 'archivebox.api'
  2. from django.test import TestCase
  3. from ninja.testing import TestClient
  4. from .routes_cli import router
  5. class ArchiveBoxCLIAPITestCase(TestCase):
  6. def setUp(self):
  7. self.client = TestClient(router)
  8. def test_add_endpoint(self):
  9. response = self.client.post("/add", json={"urls": ["http://example.com"], "tag": "testTag1,testTag2"})
  10. self.assertEqual(response.status_code, 200)
  11. self.assertTrue(response.json()["success"])
  12. def test_remove_endpoint(self):
  13. response = self.client.post("/remove", json={"filter_patterns": ["http://example.com"]})
  14. self.assertEqual(response.status_code, 200)
  15. self.assertTrue(response.json()["success"])
  16. def test_update_endpoint(self):
  17. response = self.client.post("/update", json={})
  18. self.assertEqual(response.status_code, 200)
  19. self.assertTrue(response.json()["success"])
  20. def test_list_all_endpoint(self):
  21. response = self.client.post("/list_all", json={})
  22. self.assertEqual(response.status_code, 200)
  23. self.assertTrue(response.json()["success"])