tests.py 1.1 KB

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