aboutsummaryrefslogtreecommitdiff
path: root/tests/test_server.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-08-02 19:49:41 -0500
committerChristian Cleberg <hello@cleberg.net>2025-08-02 19:49:41 -0500
commit5032dd4aff82f1deceae11269f8973e89945b893 (patch)
treea86dd7e141e0e168504b73b75f7f0634498b3e97 /tests/test_server.py
parent532e20db6ebef5e4257f437b3ab7429fa18637b3 (diff)
downloadcrumb-main.tar.gz
crumb-main.tar.bz2
crumb-main.zip
feat: add testsHEADmain
Diffstat (limited to 'tests/test_server.py')
-rw-r--r--tests/test_server.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
new file mode 100644
index 0000000..43584d8
--- /dev/null
+++ b/tests/test_server.py
@@ -0,0 +1,35 @@
+import unittest
+from flask import Flask
+from server import app
+
+class TestServer(unittest.TestCase):
+
+ def test_log_visit_post(self):
+ # Create a test client
+ client = app.test_client()
+
+ # Sample JSON data
+ data = {
+ 'title': 'Test Visit',
+ 'url': 'https://test.com',
+ 'hostname': 'test.com',
+ 'path': '/',
+ 'query': 'test',
+ 'tabId': 123,
+ 'windowId': 456,
+ 'favIconUrl': 'https://example.com/favicon.ico'
+ }
+
+ # Send a POST request
+ response = client.post('/', data=data, content_type='application/json')
+
+ # Assertions
+ self.assertEqual(response.status_code, 204)
+ # Optionally check the log file contents (for verification)
+ # This part would require additional logging setup.
+ # self.assertTrue('Test Visit' in self.get_log_content())
+
+ def test_log_visit_options(self):
+ # Send an OPTIONS request
+ response = client.options( '/', content_type='application/json')
+ self.assertEqual(response.status_code, 204) #Verify 204 No Content for OPTIONS