Skip to content

Commit 34f7669

Browse files
committed
Updated tests to mock new API stucture
1 parent c89c81a commit 34f7669

5 files changed

Lines changed: 21 additions & 24 deletions

File tree

4-auth/tests/test_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_with_credentials(app):
4141
def inner():
4242
with app.test_client() as client:
4343
with client.session_transaction() as session:
44-
session['profile'] = {'id': 'abc', 'displayName': 'Test User'}
44+
session['profile'] = {'email': 'abc@example.com', 'name': 'Test User'}
4545
session['google_oauth2_credentials'] = credentials.to_json()
4646
yield client
4747

@@ -104,12 +104,12 @@ def test_mine(self, model, client_with_credentials):
104104
# created by another user.
105105
model.create({
106106
'title': 'Book 1',
107-
'createdById': 'abc'
107+
'createdById': 'abc@example.com'
108108
})
109109

110110
model.create({
111111
'title': 'Book 2',
112-
'createdById': 'def'
112+
'createdById': 'def@example.com'
113113
})
114114

115115
# Check the "My Books" page and make sure only one of the books

5-logging/tests/test_auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_with_credentials(app):
4141
def inner():
4242
with app.test_client() as client:
4343
with client.session_transaction() as session:
44-
session['profile'] = {'id': 'abc', 'displayName': 'Test User'}
44+
session['profile'] = {'email': 'abc@example.com', 'name': 'Test User'}
4545
session['google_oauth2_credentials'] = credentials.to_json()
4646
yield client
4747

@@ -57,7 +57,6 @@ def inner():
5757
# in conftest.py
5858
@pytest.mark.usefixtures('app', 'model')
5959
class TestAuth(object):
60-
6160
def test_not_logged_in(self, app):
6261
with app.test_client() as c:
6362
rv = c.get('/books/')
@@ -105,12 +104,12 @@ def test_mine(self, model, client_with_credentials):
105104
# created by another user.
106105
model.create({
107106
'title': 'Book 1',
108-
'createdById': 'abc'
107+
'createdById': 'abc@example.com'
109108
})
110109

111110
model.create({
112111
'title': 'Book 2',
113-
'createdById': 'def'
112+
'createdById': 'def@example.com'
114113
})
115114

116115
# Check the "My Books" page and make sure only one of the books

6-pubsub/tests/test_auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_with_credentials(app):
4141
def inner():
4242
with app.test_client() as client:
4343
with client.session_transaction() as session:
44-
session['profile'] = {'id': 'abc', 'displayName': 'Test User'}
44+
session['profile'] = {'email': 'abc@example.com', 'name': 'Test User'}
4545
session['google_oauth2_credentials'] = credentials.to_json()
4646
yield client
4747

@@ -57,7 +57,6 @@ def inner():
5757
# in conftest.py
5858
@pytest.mark.usefixtures('app', 'model')
5959
class TestAuth(object):
60-
6160
def test_not_logged_in(self, app):
6261
with app.test_client() as c:
6362
rv = c.get('/books/')
@@ -105,12 +104,12 @@ def test_mine(self, model, client_with_credentials):
105104
# created by another user.
106105
model.create({
107106
'title': 'Book 1',
108-
'createdById': 'abc'
107+
'createdById': 'abc@example.com'
109108
})
110109

111110
model.create({
112111
'title': 'Book 2',
113-
'createdById': 'def'
112+
'createdById': 'def@example.com'
114113
})
115114

116115
# Check the "My Books" page and make sure only one of the books

7-gce/tests/test_auth.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_with_credentials(app):
4141
def inner():
4242
with app.test_client() as client:
4343
with client.session_transaction() as session:
44-
session['profile'] = {'id': 'abc', 'displayName': 'Test User'}
44+
session['profile'] = {'email': 'abc@example.com', 'name': 'Test User'}
4545
session['google_oauth2_credentials'] = credentials.to_json()
4646
yield client
4747

@@ -57,22 +57,21 @@ def inner():
5757
# in conftest.py
5858
@pytest.mark.usefixtures('app', 'model')
5959
class TestAuth(object):
60-
6160
def test_not_logged_in(self, app):
6261
with app.test_client() as c:
63-
rv = c.get('/books/mine')
62+
rv = c.get('/books/')
6463

65-
assert rv.status < '400'
64+
assert rv.status == '200 OK'
6665
body = rv.data.decode('utf-8')
67-
assert 'Redirecting' in body
66+
assert 'Login' in body
6867

6968
def test_logged_in(self, client_with_credentials):
7069
with client_with_credentials() as c:
71-
rv = c.get('/books/mine')
70+
rv = c.get('/books/')
7271

73-
assert rv.status < '400'
72+
assert rv.status == '200 OK'
7473
body = rv.data.decode('utf-8')
75-
assert 'Redirecting' not in body
74+
assert 'Test User' in body
7675

7776
def test_add_anonymous(self, app):
7877
data = {
@@ -105,12 +104,12 @@ def test_mine(self, model, client_with_credentials):
105104
# created by another user.
106105
model.create({
107106
'title': 'Book 1',
108-
'createdById': 'abc'
107+
'createdById': 'abc@example.com'
109108
})
110109

111110
model.create({
112111
'title': 'Book 2',
113-
'createdById': 'def'
112+
'createdById': 'def@example.com'
114113
})
115114

116115
# Check the "My Books" page and make sure only one of the books

optional-kubernetes-engine/tests/test_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def client_with_credentials(app):
4141
def inner():
4242
with app.test_client() as client:
4343
with client.session_transaction() as session:
44-
session['profile'] = {'id': 'abc', 'displayName': 'Test User'}
44+
session['profile'] = {'email': 'abc@example.com', 'name': 'Test User'}
4545
session['google_oauth2_credentials'] = credentials.to_json()
4646
yield client
4747

@@ -104,12 +104,12 @@ def test_mine(self, model, client_with_credentials):
104104
# created by another user.
105105
model.create({
106106
'title': 'Book 1',
107-
'createdById': 'abc'
107+
'createdById': 'abc@example.com'
108108
})
109109

110110
model.create({
111111
'title': 'Book 2',
112-
'createdById': 'def'
112+
'createdById': 'def@example.com'
113113
})
114114

115115
# Check the "My Books" page and make sure only one of the books

0 commit comments

Comments
 (0)