def test_add_to_branch(client, request, tester_headers): res = client.post('/mjs', headers=tester_headers, data='photoUnits.123') assert res.status_code == 200 res = client.post('/mjs/1', headers=tester_headers, data='photoUnits.123') assert res.status_code == 200 assert len(res.json['story_items']) == 1 item = res.json['story_items'][0] assert item['id'] == 'photoUnits.123' assert item['in_branch'] == [True, False, False, False]
def test_add_to_branch(client, request, tester_headers): res = client.post('/mjs', headers = tester_headers, data = 'photoUnits.123') assert res.status_code == 200 res = client.post('/mjs/1', headers=tester_headers, data = 'photoUnits.123') assert res.status_code == 200 assert len(res.json['story_items']) == 1 item = res.json['story_items'][0] assert item['id'] == 'photoUnits.123' assert item['in_branch'] == [True, False, False, False]
def test_login_scenario(client, app): ''' login scenario, starting with sending the ticket ''' mail = app.extensions.get('mail') with mail.record_messages() as outbox: ticket = client.post('/login', data={ 'email': '*****@*****.**', 'next': '/mjs' }) assert len(outbox) == 1 urls = re.findall('http\S+', outbox[0].body) assert len(urls) == 1 res = client.get(urls[0], headers={'Accept': 'application/json'}) assert res.status_code == 200 assert res.json['meta']['code'] == 200 token = res.json['response']['user']['authentication_token'] res = client.get('/', headers={'Authentication-Token': token}) assert "private" in res.data # now get the user res = client.get('/user', headers={'Authentication-Token': token}) assert res.status_code == 200 assert res.json['email'] == '*****@*****.**' hash = res.json['hash'] assert hash == hashlib.md5('*****@*****.**').hexdigest() # now let's get the public stroy res = client.get('/v1/story/' + hash) assert res.status_code == 200 assert res.json['hash'] == hash
def test_login_scenario(client, app): ''' login scenario, starting with sending the ticket ''' mail = app.extensions.get('mail') with mail.record_messages() as outbox: ticket = client.post('/login', data={'email': '*****@*****.**', 'next': '/mjs'}) assert len(outbox) == 1 urls = re.findall('http\S+', outbox[0].body) assert len(urls) == 1 login_url = urls[0] res = client.get(login_url, headers={'Accept': 'application/json'}) assert res.status_code == 200 assert res.json['meta']['code'] == 200 # test the token we got token = res.json['response']['user']['authentication_token'] res = client.get('/', headers={'Authentication-Token': token}) assert "private" in res.data # now get the user res = client.get('/user', headers={'Authentication-Token': token, 'Referer': login_url}) assert res.status_code == 200 assert res.json['email'] == '*****@*****.**' hash = res.json['hash'] assert hash == hashlib.md5('*****@*****.**').hexdigest() # now let's get the public stroy res = client.get('/v1/story/'+hash) assert res.status_code == 200 assert res.json['hash'] == hash
def test_add_item_to_mjs(client, request, tester_headers): res = client.post('/mjs', headers=tester_headers, data='photoUnits.123') assert res.status_code == 200 assert len(res.json['story_items']) == 1 item = res.json['story_items'][0] assert item['id'] == 'photoUnits.123' assert res.json['story_branches'] == 4 * ['']
def test_add_item_to_mjs(client, request, tester_headers): res = client.post('/mjs', headers = tester_headers, data = 'photoUnits.123') assert res.status_code == 200 assert len(res.json['story_items']) == 1 item = res.json['story_items'][0] assert item['id'] == 'photoUnits.123' assert res.json['story_branches'] == 4*['']
def test_bad_next_login(client, app): ''' post a login with bad `next` and ensure the user has the default one ''' mail = app.extensions.get('mail') with mail.record_messages() as outbox: ticket = client.post('/login', data={'email': '*****@*****.**', 'next': '/login/badwolf'}) assert len(outbox) == 1 urls = re.findall('http\S+', outbox[0].body) assert len(urls) == 1 user = app.user_datastore.get_user('*****@*****.**') assert user.next == app.config['DEFAULT_NEXT'] # cleanup app.user_datastore.delete_user(user)
def test_bad_next_login(client, app): ''' post a login with bad `next` and ensure the user has the default one ''' mail = app.extensions.get('mail') with mail.record_messages() as outbox: ticket = client.post('/login', data={ 'email': '*****@*****.**', 'next': '/login/badwolf' }) assert len(outbox) == 1 urls = re.findall('http\S+', outbox[0].body) assert len(urls) == 1 user = app.user_datastore.get_user('*****@*****.**') assert user.next == app.config['DEFAULT_NEXT'] # cleanup app.user_datastore.delete_user(user)
def test_illegal_add_to_branch(client, request, tester_headers): res = client.post('/mjs/1', headers=tester_headers, data = 'personalities.456') assert res.status_code == 400
def test_mjs_rename_branch(client, tester_headers): res = client.post('/mjs/1/name', headers=tester_headers, data = 'mothers') assert res.status_code == 200 assert res.json['story_branches'] == ['mothers', '', '', '']
def test_illegal_add_to_branch(client, request, tester_headers): res = client.post('/mjs/1', headers=tester_headers, data='personalities.456') assert res.status_code == 400
def test_mjs_rename_branch(client, tester_headers): res = client.post('/mjs/1/name', headers=tester_headers, data='mothers') assert res.status_code == 200 assert res.json['story_branches'] == ['mothers', '', '', '']