-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change id to element_id for Cypher queries.
Update `test_register` and auth `resgister` route
- Loading branch information
Showing
3 changed files
with
16 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,21 +63,21 @@ def app(test_db_driver): | |
|
||
# This function must be called for every new test node created | ||
def add_test_label(node): | ||
query = "MATCH (n) WHERE id(n) = $node_id SET n:TestData" | ||
params = {'node_id': node.id} | ||
query = "MATCH (n) WHERE elementId(n) = $node_id SET n:TestData" | ||
params = {'node_id': node.element_id} | ||
db.cypher_query(query, params) | ||
|
||
|
||
# This function must be called for every new test relationship created | ||
def add_test_property_to_rel(start_node, rel_type, end_node): | ||
query = f""" | ||
MATCH (a)-[r:{rel_type}]-(b) | ||
WHERE id(a) = $start_id AND id(b) = $end_id | ||
WHERE elementId(a) = $start_id AND elementId(b) = $end_id | ||
SET r.test_data = true | ||
""" | ||
params = { | ||
'start_id': start_node.id, | ||
'end_id': end_node.id | ||
'start_id': start_node.element_id, | ||
'end_id': end_node.element_id | ||
} | ||
db.cypher_query(query, params) | ||
|
||
|
@@ -153,7 +153,7 @@ def example_partner_member(example_user: User): | |
contact_email="[email protected]", | ||
member_association=[ | ||
PartnerMember( | ||
user_id=example_user.id, | ||
user_id=example_user.uid, | ||
role=MemberRole.MEMBER.value, | ||
date_joined=datetime.now(), | ||
is_active=True, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,12 @@ | |
], | ||
) | ||
def test_register( | ||
db_session, client, email, password, | ||
db_session, client, example_user, email, password, | ||
firstname, lastname, phone_number, | ||
expected_status_code | ||
): | ||
if email == "[email protected]": | ||
email = example_user.email | ||
res = client.post( | ||
"api/v1/auth/register", | ||
json={ | ||
|
@@ -35,9 +37,8 @@ def test_register( | |
assert res.status_code == expected_status_code | ||
|
||
if expected_status_code == 200: | ||
assert res.json["status"] == "ok" | ||
assert res.json["status"] == "OK" | ||
assert res.json["message"] == "Successfully registered." | ||
assert res.json["access_token"] == "mocked_access_token" | ||
assert "Set-Cookie" in res.headers | ||
elif expected_status_code == 409 and email == "[email protected]": | ||
assert res.json["status"] == "Conflict" | ||
|
@@ -55,7 +56,7 @@ def test_register( | |
[("my_password", 200), ("bad_password", 401), (None, 422)], | ||
) | ||
def test_login( | ||
mock_db_session, | ||
db_session, | ||
client, example_user, password, expected_status_code | ||
): | ||
with patch('backend.database.User.get_by_email') as mock_get_by_email: | ||
|
@@ -73,7 +74,7 @@ def test_login( | |
assert res.status_code == expected_status_code | ||
|
||
|
||
def test_jwt(client, mock_db_session, example_user, mock_access_token): | ||
def test_jwt(client, db_session, example_user, mock_access_token): | ||
with patch('backend.database.User.nodes.get_or_none') as mock_get_or_none, \ | ||
patch('flask_jwt_extended.decode_token') as mock_decode_token: | ||
|
||
|
@@ -98,7 +99,7 @@ def test_jwt(client, mock_db_session, example_user, mock_access_token): | |
|
||
|
||
def test_auth_test_header( | ||
mock_db_session, client, example_user, mock_access_token): | ||
db_session, client, example_user, mock_access_token): | ||
login_res = client.post( | ||
"api/v1/auth/login", | ||
json={"email": example_user.email, "password": "my_password"}, | ||
|
@@ -118,7 +119,7 @@ def test_auth_test_header( | |
assert test_res.status_code == 200 | ||
|
||
|
||
def test_auth_test_cookie(mock_db_session, client, example_user): | ||
def test_auth_test_cookie(db_session, client, example_user): | ||
client.post( | ||
"api/v1/auth/login", | ||
json={"email": example_user.email, "password": "my_password"}, | ||
|
@@ -133,7 +134,7 @@ def test_auth_test_cookie(mock_db_session, client, example_user): | |
assert test_res.status_code == 200 | ||
|
||
|
||
def test_access_token_fixture(mock_db_session, mock_access_token): | ||
def test_access_token_fixture(db_session, mock_access_token): | ||
assert len(mock_access_token) > 0 | ||
|
||
|
||
|