From 51582f9887bf72e78012ebd560917db3a4587a50 Mon Sep 17 00:00:00 2001 From: adipai Date: Fri, 24 Nov 2023 15:34:19 -0500 Subject: [PATCH] Refactored test suite --- tests/test_history.py | 10 +++++++++ tests/test_history.txt | 12 +++++++++++ tests/test_module.py | 47 ------------------------------------------ tests/test_profile.py | 19 ----------------- tests/test_register.py | 24 --------------------- 5 files changed, 22 insertions(+), 90 deletions(-) delete mode 100644 tests/test_module.py delete mode 100644 tests/test_profile.py delete mode 100644 tests/test_register.py diff --git a/tests/test_history.py b/tests/test_history.py index a8ff8121..dc558da6 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -1,5 +1,15 @@ import datetime import unittest +import os +import sys +# Get the current script's directory +current_dir = os.path.dirname(os.path.abspath(__file__)) + +# Get the parent directory +parent_dir = os.path.dirname(current_dir) + +# Add the parent directory to the Python path +sys.path.append(parent_dir) from service import history diff --git a/tests/test_history.txt b/tests/test_history.txt index d60a14db..ecb5cfc7 100644 --- a/tests/test_history.txt +++ b/tests/test_history.txt @@ -16,3 +16,15 @@ 23/11 14:31:50 User: How are you? 23/11 14:31:50 Assistant: Mocked response + +24/11 12:24:35 User: How are you? +24/11 12:24:35 Assistant: Mocked response + +24/11 12:28:09 User: How are you? +24/11 12:28:09 Assistant: Mocked response + +24/11 12:51:51 User: How are you? +24/11 12:51:51 Assistant: Mocked response + +24/11 15:29:49 User: How are you? +24/11 15:29:49 Assistant: Mocked response diff --git a/tests/test_module.py b/tests/test_module.py deleted file mode 100644 index fa222125..00000000 --- a/tests/test_module.py +++ /dev/null @@ -1,47 +0,0 @@ -import unittest -# from application import app - - -class BasicTestCase(unittest.TestCase): - - def test_logout(self): - pass - - # self.app = app.test_client() - # ans =self.app.get('/logout') - # self.assertEqual(ans.status_code, 200) - - # def test_home(self): - # self.app = app.test_client() - # ans =self.app.get('/home') - # self.assertEqual(ans.status_code, 302) - - # def test_login(self): - # self.app = app.test_client() - # ans =self.app.get('/login') - # self.assertEqual(ans.status_code, 200) - - # def test_register(self): - # self.app = app.test_client() - # ans =self.app.get('/register') - # self.assertEqual(ans.status_code, 200) - - # def test_dashboard(self): - # self.app = app.test_client() - # ans =self.app.get('/dashboard') - # self.assertEqual(ans.status_code, 200) - - # def test_friends(self): - # self.app= app.test_client() - # ans=self.app.get('/friends') - # self.assertEqual(ans.status_code, 200) - - # def test_calories(self): - # self.app= app.test_client() - # ans=self.app.get('/calories') - # self.assertEqual(ans.status_code, 302) - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_profile.py b/tests/test_profile.py deleted file mode 100644 index 3816cc02..00000000 --- a/tests/test_profile.py +++ /dev/null @@ -1,19 +0,0 @@ -# import pytest -# from unittest.mock import patch -# from application import app -# import mongomock - -# @pytest.fixture -# def client(): -# with mongomock.patch(): -# with app.test_client() as client: -# yield client - -# def test_get_user_profile(client): -# db = mongomock.MongoClient().db - -# db.items.insert_one( -# {"email":"ojaskulkarni100@gmail.com" ,"weight":90, "height":180, "target_weight":80,"goal":"75"}, -# ) -# response = client.get("/user_profile") -# assert response.status_code == 302 diff --git a/tests/test_register.py b/tests/test_register.py deleted file mode 100644 index 4251af47..00000000 --- a/tests/test_register.py +++ /dev/null @@ -1,24 +0,0 @@ -import pytest -# from application import app - -# @pytest.fixture -# def client(): -# with mongomock.patch(): -# with app.test_client() as client: -# yield client - -# def test_get_user(client): -# db = mongomock.MongoClient().db -# db.items.insert_one( -# {"name": "OjasTest", "pwd":"hshaksjn", "weight":90, "height":180, "target_weight":80, "start_date":"2023-10-15", "target_date": -# "2023-11-15"}, -# ) -# response = client.get("/register") -# assert response.status_code == 200 - -# def test_insert_user(client): -# # Make a POST request to the /items endpoint with a JSON payload -# response = client.post("/register", json={"name": "OjasTest", "pwd":"hshaksjn", "weight":"90", "height":"180", "target_weight":"80", "start_date":"2023-10-15", "target_date": -# "2023-11-15"}) -# # Assert the response status code is 201 Created -# assert response.status_code == 200