-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
86 lines (54 loc) · 3.27 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import crud
import unittest
import server
import json
class MyWebsiteTests(unittest.TestCase):
"""Testing Flask server"""
def test_new_country_is_shown(self):
"""When user types in a country, it should bring you to the '/country-search' route and it should included a country's population."""
client = server.app.test_client()
result = client.get('/country-search')
self.assertIn(b'Population', result.data)
def test_timeline_shown(self):
"""Tests that timeline map page is displayed."""
client = server.app.test_client()
result = client.get('/covid-timeline')
self.assertIn(b'Global COVID-19 Timeline', result.data)
# def test_registration_page_shown(self):
# """Tests that registration page is displayed."""
# client = server.app.test_client()
# result = client.get('/register')
# self.assertIn(b'Already have an account?', result.data)
# def test_user_registration(self):
# """POST request test."""
# client = server.app.test_client()
# result = client.post('/user-registration-info', data={'first_name': 'Jane',
# 'last_name': 'Doe',
# 'email': '[email protected]',
# 'password': 'password1'})
# self.assertIn(b'Create Your Account', result.data)
# def test_if_user_created(self):
# """Checks if user added to database after entering all required credentials."""
# client = server.app.test_client()
# result = client.get('/user-registration-check')
# user_instance = crud.create_user_instance("test0", "test1", "test2", "test3")
# self.assertTrue(user_instance.first_name == "test0")
# self.assertTrue(user_instance.last_name == "test1")
# self.assertTrue(user_instance.email == "test2")
# self.assertTrue(user_instance.password == "test3")
# Michael
# result = client.post('/user-registration-check',
# data=json.dumps(dict(email= '[email protected]',password= 'password1', firstName='Jane', lastName='Doe')),
# content_type="application/json")
# def test_user_validation(self):
# """Check the route that validates a user. Provide a pretend email/password and check the return is a dictionary with an unsuccessful status"""
# client = server.app.test_client()
# result = client.post('/user-registration-check',
# data=json.dumps(dict(email= '[email protected]', password= 'test1234', firstName="bad", lastName="guy")),
# content_type='application/json')
# self.assertEqual(result, {"result": "unsuccessful", "status": "USER ALREADY EXISTS OR CREDENTIALS INVALID."})
def test_user_taken_to_timeline(self):
""" Tests that user is taken to COVID timeline page after receiving dictionary response with 'result': 'sucessful' """
client = server.app.test_client()
result = client.post('/user-registration-check')
self.assertTrue(result, {"result": "sucessful", "status": "LOGIN WITH YOUR NEW CREDENTIALS."})