Update test_views.py
This commit is contained in:
parent
1d9b7afc77
commit
3ea63036f5
1 changed files with 78 additions and 1 deletions
|
@ -11,20 +11,29 @@ class TestViews(TestCase):
|
||||||
|
|
||||||
def test_views(self):
|
def test_views(self):
|
||||||
#DEFAULT_VIEW
|
#DEFAULT_VIEW
|
||||||
|
print("Testing login view...")
|
||||||
response = self.client.get(self.list_url)
|
response = self.client.get(self.list_url)
|
||||||
|
|
||||||
self.assertEquals(response.status_code, 200)
|
self.assertEquals(response.status_code, 200)
|
||||||
self.assertTemplateUsed(response, 'frontend/index.html')
|
self.assertTemplateUsed(response, 'frontend/index.html')
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#CONTENT_VIEW
|
#CONTENT_VIEW
|
||||||
|
print("Testing content view...")
|
||||||
response = self.client.get(self.detail_url)
|
response = self.client.get(self.detail_url)
|
||||||
|
|
||||||
self.assertEquals(response.status_code, 302)
|
self.assertEquals(response.status_code, 302)
|
||||||
|
if response.status_code == 302:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#ACCOUNT_MANAGER
|
#ACCOUNT_MANAGER
|
||||||
|
print("Testing account manager view...")
|
||||||
response = self.client.get(reverse('account_manager'))
|
response = self.client.get(reverse('account_manager'))
|
||||||
|
|
||||||
self.assertEquals(response.status_code, 302)
|
self.assertEquals(response.status_code, 302)
|
||||||
|
if response.status_code == 302:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#API
|
#API
|
||||||
data = {
|
data = {
|
||||||
|
@ -34,6 +43,8 @@ class TestViews(TestCase):
|
||||||
"diaryUrl": "http://cufs.fakelog.cf/"
|
"diaryUrl": "http://cufs.fakelog.cf/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print("Testing login...")
|
||||||
|
|
||||||
response = self.client.post(reverse('login'), content_type='application/xml', data=json.dumps(data))
|
response = self.client.post(reverse('login'), content_type='application/xml', data=json.dumps(data))
|
||||||
cookies_data = response.json()
|
cookies_data = response.json()
|
||||||
|
|
||||||
|
@ -41,95 +52,153 @@ class TestViews(TestCase):
|
||||||
|
|
||||||
students = cookies_data['data']['students']['data']
|
students = cookies_data['data']['students']['data']
|
||||||
#JAN
|
#JAN
|
||||||
|
print("Testing registering as Jan Kowalski...")
|
||||||
jan_data = students[0]
|
jan_data = students[0]
|
||||||
cookies_data['data']['students']['data'] = [jan_data]
|
cookies_data['data']['students']['data'] = [jan_data]
|
||||||
get_data_test(self.client, cookies_data, self.assertEquals)
|
get_data_test(self.client, cookies_data, self.assertEquals)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
#JOANNA
|
#JOANNA
|
||||||
|
print("Testing registering as Joanna Czerwińska...")
|
||||||
joanna_data = students[3]
|
joanna_data = students[3]
|
||||||
cookies_data['data']['students']['data'] = [joanna_data]
|
cookies_data['data']['students']['data'] = [joanna_data]
|
||||||
get_data_test(self.client, cookies_data, self.assertEquals)
|
get_data_test(self.client, cookies_data, self.assertEquals)
|
||||||
log_out_test(self.client, self.assertEquals)
|
log_out_test(self.client, self.assertEquals)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
|
|
||||||
def get_data_test(client, cookies_data, assertEquals):
|
def get_data_test(client, cookies_data, assertEquals):
|
||||||
#GRADES
|
#GRADES
|
||||||
|
print("Testing grades...")
|
||||||
response = client.post(reverse('grades'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('grades'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#TIMETABLE
|
#TIMETABLE
|
||||||
|
print("Testing timetable...")
|
||||||
response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
response = client.post(reverse('timetable'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#EXAMS
|
#EXAMS
|
||||||
|
print("Testing exams...")
|
||||||
response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
response = client.post(reverse('exams'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#HOMEWORKS
|
#HOMEWORKS
|
||||||
|
print("Testing homeworks...")
|
||||||
response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
response = client.post(reverse('homeworks'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#ATTENDANCE
|
#ATTENDANCE
|
||||||
|
print("Testing attendance...")
|
||||||
response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
response = client.post(reverse('attendance'), content_type='application/xml', data=json.dumps({'cookies': json.dumps(cookies_data), 'week': 0}))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#NOTES
|
#NOTES
|
||||||
|
print("Testing notes...")
|
||||||
response = client.post(reverse('notes'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('notes'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#SCHOOL DATA
|
#SCHOOL DATA
|
||||||
|
print("Testing school data...")
|
||||||
response = client.post(reverse('school_data'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('school_data'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#DASHBOARD
|
#DASHBOARD
|
||||||
|
print("Testing dashboard...")
|
||||||
response = client.post(reverse('dashboard'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('dashboard'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#MOBILE ACCESS
|
#MOBILE ACCESS
|
||||||
#REGISTERED DEVICES
|
#REGISTERED DEVICES
|
||||||
|
print("Testing registered devices...")
|
||||||
response = client.post(reverse('registered_devices'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('registered_devices'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#REGISTER DEVICE
|
#REGISTER DEVICE
|
||||||
|
print("Testing registering device...")
|
||||||
response = client.post(reverse('register_device'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('register_device'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#MESSAGES
|
#MESSAGES
|
||||||
#RECEIVED MESSAGES
|
#RECEIVED MESSAGES
|
||||||
|
print("Testing received messages...")
|
||||||
messages_ids = []
|
messages_ids = []
|
||||||
response = client.post(reverse('received_messages'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('received_messages'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
messages_ids.append([response.json()['data']])
|
messages_ids.append([response.json()['data']])
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#SENT MESSAGES
|
#SENT MESSAGES
|
||||||
|
print("Testing sent messages...")
|
||||||
response = client.post(reverse('sent_messages'), content_type='appication/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('sent_messages'), content_type='appication/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
for id in response.json()['data']:
|
for id in response.json()['data']:
|
||||||
messages_ids.append(id)
|
messages_ids.append(id)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#DELETED MESSAGES
|
#DELETED MESSAGES
|
||||||
|
print("Testing deleted messages...")
|
||||||
response = client.post(reverse('deleted_messages'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('deleted_messages'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
messages_ids.append([response.json()['data']])
|
messages_ids.append([response.json()['data']])
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#GET RECIPIENTS
|
#GET RECIPIENTS
|
||||||
|
print("Testing getting recipients...")
|
||||||
response = client.post(reverse('recipients'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('recipients'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
recipients = response.json()['addressee']['data']
|
recipients = response.json()['addressee']['data']
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#STUDENT DATA
|
#STUDENT DATA
|
||||||
|
print("Testing student data...")
|
||||||
response = client.post(reverse('student_data'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('student_data'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#STATS
|
#STATS
|
||||||
#PARTIAL
|
#PARTIAL
|
||||||
|
print("Testing partial grades stats...")
|
||||||
response = client.post(reverse('partial'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('partial'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#YEAR
|
#YEAR
|
||||||
|
print("Testing year grades stats...")
|
||||||
response = client.post(reverse('year'), content_type='application/xml', data=json.dumps(cookies_data))
|
response = client.post(reverse('year'), content_type='application/xml', data=json.dumps(cookies_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#SEND MESSAGE
|
#SEND MESSAGE
|
||||||
|
print("Testing sending message...")
|
||||||
for recipient in recipients:
|
for recipient in recipients:
|
||||||
send_data = {
|
send_data = {
|
||||||
'cookies_data': json.dumps(cookies_data),
|
'cookies_data': json.dumps(cookies_data),
|
||||||
|
@ -139,8 +208,11 @@ def get_data_test(client, cookies_data, assertEquals):
|
||||||
}
|
}
|
||||||
response = client.post(reverse('send_message'), content_type='application/xml', data=json.dumps(send_data))
|
response = client.post(reverse('send_message'), content_type='application/xml', data=json.dumps(send_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
#GETTING MESSAGE CONTENT
|
#GETTING MESSAGE CONTENT
|
||||||
|
print("Testing getting content of message...")
|
||||||
for id in messages_ids:
|
for id in messages_ids:
|
||||||
send_data = {
|
send_data = {
|
||||||
'cookies_data': json.dumps(cookies_data),
|
'cookies_data': json.dumps(cookies_data),
|
||||||
|
@ -148,8 +220,13 @@ def get_data_test(client, cookies_data, assertEquals):
|
||||||
}
|
}
|
||||||
response = client.post(reverse('message_content'), content_type='application/xml', data=json.dumps(send_data))
|
response = client.post(reverse('message_content'), content_type='application/xml', data=json.dumps(send_data))
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Passed!")
|
||||||
|
|
||||||
def log_out_test(client, assertEquals):
|
def log_out_test(client, assertEquals):
|
||||||
#LOG OUT
|
#LOG OUT
|
||||||
|
print("Testing logging out...")
|
||||||
response = client.get(reverse('log_out'), content_type='application/xml')
|
response = client.get(reverse('log_out'), content_type='application/xml')
|
||||||
assertEquals(response.status_code, 200)
|
assertEquals(response.status_code, 200)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("\033[92m Passed!")
|
||||||
|
|
Loading…
Reference in a new issue