Skip to content

Commit 9d8a0e9

Browse files
committed
Added remaining tests for core functionality TDD
1 parent e06f25f commit 9d8a0e9

File tree

2 files changed

+144
-39
lines changed

2 files changed

+144
-39
lines changed

tests/test_helper_methods.py

Lines changed: 133 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,62 @@
22
from test_properties import *
33

44

5+
class TestAuthentication(object):
6+
def test_login(self):
7+
# TEST ENV SETUP
8+
# make sure the valid account is logged out first before trying to login with the account
9+
print('*'*50)
10+
print('TEST ENVIRONMENT SETUP')
11+
print(disconnect(*VALID_ZV_CONNECTION)[1])
12+
print('*'*50)
13+
14+
# trying to login with valid credentials
15+
assert connect(*VALID_ZV_CONNECTION) == (
16+
True, 'You have successfully logged into the Zevere account {} with your telegram account of {}'.format(VALID_ZV_CONNECTION[0], VALID_ZV_CONNECTION[1]))
17+
18+
# trying to login with invalid credentials
19+
assert connect(*INVALID_ZV_CONNECTION) == (
20+
False, 'You have provided invalid login credentials.')
21+
22+
# def test_is_authenticated(self):
23+
# TEST ENV SETUP
24+
# make sure the valid account is logged in first before trying to logout with the account
25+
# connect(*VALID_ZV_CONNECTION)
26+
# # test authentication for valid tg->zv connection
27+
# # should return True and the zv_user the tg user is auth'd as
28+
# assert is_authenticated(
29+
# *VALID_ZV_CONNECTION) == (True, VALID_ZV_CONNECTION[0])
30+
31+
# # test authentication for invalid tg->zv connection
32+
# # should return False and None since tg user not auth'd
33+
# assert is_authenticated(*INVALID_ZV_CONNECTION) == (False, None)
34+
35+
def test_logout(self):
36+
37+
# TEST ENV SETUP
38+
# make sure the valid account is logged in first before trying to logout with the account
39+
print('*'*50)
40+
print('TEST ENVIRONMENT SETUP')
41+
print(connect(*VALID_ZV_CONNECTION)[1])
42+
print('*'*50)
43+
44+
# trying to logout valid telegram to zevere connection
45+
assert disconnect(*VALID_ZV_CONNECTION) == (
46+
True, 'You have successfully been logged out from {}'.format(VALID_ZV_CONNECTION[0]))
47+
48+
# trying to logout with invalid telegram to zevere connection
49+
assert disconnect(*INVALID_ZV_CONNECTION) == (
50+
False, 'You are not logged in to any Zevere account.')
51+
52+
553
class TestListManagmement(object):
54+
# TEST ENV SETUP
55+
# make sure the valid account is logged in first before trying to logout with the account
56+
print('*'*50)
57+
print('TEST ENVIRONMENT SETUP')
58+
print(connect(*VALID_ZV_CONNECTION)[1])
59+
print('*'*50)
60+
661
def test_get_all_lists(self):
762
# returns list of lists for existant zevere user
863
assert type(get_all_lists(VALID_ZEVERE_USER)) == list
@@ -48,41 +103,81 @@ def test_delete_list(self):
48103
# assert get_list_by_id(INVALID_LIST_ID) is None
49104

50105

51-
class TestAuthentication(object):
52-
def test_login(self):
53-
# TEST ENV SETUP
54-
# make sure the valid account is logged out first before trying to login with the account
55-
disconnect(*VALID_ZV_CONNECTION)
56-
57-
# trying to login with valid credentials
58-
assert connect(*VALID_ZV_CONNECTION) == (
59-
True, 'You have successfully logged into the Zevere account {} with your telegram account of {}'.format(VALID_ZV_CONNECTION[0], VALID_ZV_CONNECTION[1]))
60-
61-
# trying to login with invalid credentials
62-
assert connect(*INVALID_ZV_CONNECTION) == (
63-
False, 'You have provided invalid login credentials.')
64-
pass
65-
66-
# def test_is_authenticated(self):
67-
# # test authentication for valid tg->zv connection
68-
# # should return True and the zv_user the tg user is auth'd as
69-
# assert is_authenticated(
70-
# *VALID_ZV_CONNECTION) == (True, VALID_ZV_CONNECTION[0])
71-
72-
# # test authentication for invalid tg->zv connection
73-
# # should return False and None since tg user not auth'd
74-
# assert is_authenticated(*INVALID_ZV_CONNECTION) == (False, None)
75-
76-
def test_logout(self):
77-
78-
# TEST ENV SETUP
79-
# make sure the valid account is logged in first before trying to logout with the account
80-
connect(*VALID_ZV_CONNECTION)
81-
82-
# trying to logout valid telegram to zevere connection
83-
assert disconnect(*VALID_ZV_CONNECTION) == (
84-
True, 'You have successfully been logged out from {}'.format(VALID_ZV_CONNECTION[0]))
85-
86-
# trying to logout with invalid telegram to zevere connection
87-
assert disconnect(*INVALID_ZV_CONNECTION) == (
88-
False, 'You are not logged in to any Zevere account.')
106+
# class TestTaskManagement(object):
107+
# # TEST ENV SETUP
108+
# # make sure the valid account is logged in first before trying to logout with the account
109+
# print('*'*50)
110+
# print('TEST ENVIRONMENT SETUP')
111+
# print(connect(*VALID_ZV_CONNECTION)[1])
112+
# print('The list with id = {} was successfully created'.format(
113+
# create_list(VALID_ZEVERE_USER, LIST_TITLE, LIST_DESCRIPTION)))
114+
# print('*'*50)
115+
116+
# def test_get_all_tasks(self):
117+
# # returns list of tasks for existant zevere user and his/her owned list
118+
# assert type(get_all_tasks(VALID_ZEVERE_USER, VALID_LIST_ID)) == list
119+
120+
# # should return null for existant zevere user but an unknown list
121+
# assert get_all_tasks(VALID_ZEVERE_USER, INVALID_LIST_ID) is None
122+
123+
# # should return null for non existant zevere users
124+
# assert get_all_tasks(INVALID_ZEVERE_USER, VALID_LIST_ID) is None
125+
126+
# def test_create_task(self):
127+
# # create new task for the zevere user for an existing list
128+
# # should return the id of the task which is the task title
129+
# # toLower and spaces replaced with underscore characters
130+
# assert create_task(VALID_ZEVERE_USER, VALID_LIST_ID, TASK_TITLE,
131+
# TASK_DESCRIPTION) == (True, TASK_TITLE.strip().lower().replace(' ', '_'))
132+
133+
# # creating a task that already exists for the zevere user's list
134+
# # should return None since the task is not created again
135+
# assert create_task(VALID_ZEVERE_USER, VALID_LIST_ID,
136+
# TASK_TITLE, TASK_DESCRIPTION) == (False, None)
137+
138+
# # creating a task for a non-existent list
139+
# # should return None since the task cannot be created
140+
# assert create_task(VALID_ZEVERE_USER, INVALID_LIST_ID,
141+
# TASK_TITLE, TASK_DESCRIPTION) == (False, None)
142+
143+
# # creating a task for a list not belonging to the connected zevere user
144+
# # should return None since the task will not be created
145+
# assert create_task(VALID_ZEVERE_USER, VALID_LIST_ID2,
146+
# TASK_TITLE, TASK_DESCRIPTION) == (False, None)
147+
148+
# # creating a list with an invalid zevere user
149+
# # should return None since the list is not created
150+
# assert create_task(INVALID_ZEVERE_USER, VALID_LIST_ID,
151+
# LIST_TITLE, LIST_DESCRIPTION) == (False, None)
152+
153+
# def test_delete_task(self):
154+
# # trying to delete a task not part of the list passed
155+
# # in as an argument should return False and None as no
156+
# # task was deleted
157+
# assert delete_task(*VALID_LIST_AND_OWNER, VALID_TASK_ID2) == (
158+
# False, None)
159+
160+
# # trying to delete a task by an id that does not exist
161+
# # should return False and None as no list was deleted
162+
# assert delete_list(*INVALID_OWNER_AND_LIST, INVALID_TASK_ID) == (
163+
# False, None)
164+
165+
# # trying to delete a task part of the list owned by th zv_user passed
166+
# # in as an argument should return True and the id of the list that was deleted
167+
# assert delete_list(*VALID_LIST_AND_OWNER, VALID_TASK_ID) == (
168+
# True, VALID_TASK_ID)
169+
170+
# def test_get_task_by_id(self):
171+
# # try to get the task we created in the above test case
172+
# result = get_task_by_id(VALID_TASK_ID)
173+
# assert hasattr(result, 'id') & result['id'] == VALID_TASK_ID
174+
175+
# # try to get a non existent task
176+
# assert get_task_by_id(INVALID_TASK_ID) is None
177+
178+
# print('*'*50)
179+
# print('TEST ENVIRONMENT CLEANUP')
180+
# print('The list with id = {} was successfully deleted'.format(
181+
# delete_list(*VALID_LIST_AND_OWNER)[1]))
182+
# print(disconnect(*VALID_ZV_CONNECTION)[1])
183+
# print('*'*50)

tests/test_properties.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@
88
INVALID_ZV_CONNECTION = INVALID_ZEVERE_USER, INVALID_TG_ID
99

1010
LIST_TITLE = "Centennial College School Work"
11+
LIST_TITLE2 = "Test List with No Description"
1112
LIST_DESCRIPTION = "This task list is for managing all the school work I have to do from class."
1213

1314
VALID_LIST_ID = LIST_TITLE.strip().lower().replace(' ', '_')
15+
VALID_LIST_ID2 = LIST_TITLE2.strip().lower().replace(' ', '_')
1416
INVALID_LIST_ID = 'xxx. chalbye choo foo?'
1517

1618
VALID_LIST_AND_OWNER = VALID_ZEVERE_USER, VALID_LIST_ID
1719
INVALID_OWNER_VALID_LIST = INVALID_ZEVERE_USER, VALID_LIST_ID
18-
INVALID_OWNER_AND_LIST = VALID_ZEVERE_USER, INVALID_LIST_ID
20+
INVALID_OWNER_AND_LIST = INVALID_ZEVERE_USER, INVALID_LIST_ID
21+
22+
TASK_TITLE = 'Rumi Essay'
23+
TASK_TITLE2 = 'Test Task with No Description'
24+
TASK_DESCRIPTION = 'Write 100 page research essay on the philosophical teachings of Rumi'
25+
26+
VALID_TASK_ID = TASK_TITLE.strip().lower().replace(' ', '_')
27+
VALID_TASK_ID2 = TASK_TITLE2.strip().lower().replace(' ', '_')
28+
INVALID_TASK_ID = 'monsTer W3nk4r?? W0t 1s th|s?'

0 commit comments

Comments
 (0)