Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated model.py and created test cases for CRUD operations #36

Merged
merged 15 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import numpy as np
import string

df = pd.read_csv(
'C:\\Users\\Shivam\\Desktop\\calorieApp_server\\model\\cleaned_data.csv')
df = pd.read_csv('model/cleaned_data.csv')
index_list = df.index.tolist()

client = pymongo.MongoClient('mongodb://localhost:27017')
Expand Down Expand Up @@ -146,9 +145,7 @@ def find_subset(weight: list, req_sum: int):
print('Consume one of these items', u_cal_food[i],'*',list_occ[i][1], 'times')
'''

diet_report = open(
'C:\\Users\\Shivam\\Desktop\\calorieApp_server\\model\\diet_guide.txt',
"wt") #path
diet_report = open('model/diet_guide.txt', "wt") #path

for i in range(len(u_cal)):
fl = 'Consume one of these items', u_cal_food[i], '*', list_occ[i][
Expand Down
4 changes: 2 additions & 2 deletions tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class TestHistoryService(unittest.TestCase):
def test_total_calories_to_burn_a(self):
tw = 90
cw = 100
self.assertEquals(history.total_calories_to_burn(tw, cw), -77000)
self.assertEqual(history.total_calories_to_burn(tw, cw), -77000)

def test_total_calories_to_burn_b(self):
tw = 100
cw = 90
self.assertEquals(history.total_calories_to_burn(tw, cw), 77000)
self.assertEqual(history.total_calories_to_burn(tw, cw), 77000)

def test_calories_to_burn_a(self):
target_calories = -77000
Expand Down
78 changes: 35 additions & 43 deletions tests/test_module.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
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

# 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, 200)
#
# def test_user_profile(self):
# self.app= app.test_client()
# ans=self.app.get('/user_profile')
# self.assertEqual(ans.status_code, 200)
#
# def test_history(self):
# self.app= app.test_client()
# ans=self.app.get('/history')
# self.assertEqual(ans.status_code, 200)

if __name__ == '__main__':
unittest.main()
19 changes: 19 additions & 0 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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":"[email protected]" ,"weight":90, "height":180, "target_weight":80,"goal":"75"},
# )
# response = client.get("/user_profile")
# assert response.status_code == 302
24 changes: 24 additions & 0 deletions tests/test_register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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
Loading