This repository has been archived by the owner on Jan 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
end_to_end_test.py
37 lines (37 loc) · 1.67 KB
/
end_to_end_test.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
import unittest
import json
import requests
import time
import os
TOKEN = os.getenv('TOKEN', '')
class EndpointTestCase(unittest.TestCase):
# def test(self):
# users = [{ 'id':'42', 'country': 'de' }, { 'id':'42', 'country': 'de' }]
# expected_users = [{ 'id':42, 'country': 'de' }, { 'id':42, 'country': 'de' }]
# for user in users:
# resp = requests.post('http://localhost:3000/users', json=user, headers={'access-token': TOKEN})
# self.assertEqual(resp.status_code, 200)
# time.sleep(90)
# resp = requests.get('http://localhost:3003/users', headers={'access-token': TOKEN})
# returned_users = resp.json()
# print(returned_users)
# print(type(returned_users))
# self.assertEqual(len(returned_users), 2)
# self.assertDictContainsSubset(expected_users[0], returned_users[0])
# self.assertDictContainsSubset(expected_users[1], returned_users[1])
def test_target_users(self):
target_users = [{'user_id':'42'}, {'user_id':'43'}]
expected_target_users = [{'user_id':42}, {'user_id':43}]
for t in target_users:
resp = requests.post('http://localhost:3000/target_users', json=t, headers={'access-token': TOKEN})
self.assertEqual(resp.status_code, 200)
time.sleep(30)
resp = requests.get('http://localhost:3003/target_users', headers={'access-token': TOKEN})
returned_target_users = resp.json()
print(returned_target_users)
print(type(returned_target_users))
self.assertEqual(len(returned_target_users), 2)
self.assertDictContainsSubset(expected_target_users[0], returned_target_users[0])
self.assertDictContainsSubset(expected_target_users[1], returned_target_users[1])
time.sleep(20)
unittest.main()