forked from codeforboston/police-data-trust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codeforboston#284 - Updated the Create endpoint to require a CONTRIBU…
…TOR role and updates the unit tests to use a contributor user.
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
example_email = "[email protected]" | ||
admin_email = "[email protected]" | ||
contributor_email = "[email protected]" | ||
example_password = "my_password" | ||
|
||
|
||
|
@@ -63,7 +64,6 @@ def example_user(db_session): | |
db_session.commit() | ||
return user | ||
|
||
|
||
@pytest.fixture | ||
def admin_user(db_session): | ||
user = User( | ||
|
@@ -78,6 +78,19 @@ def admin_user(db_session): | |
|
||
return user | ||
|
||
@pytest.fixture | ||
def contributor_user(db_session): | ||
user = User( | ||
email=contributor_email, | ||
password=user_manager.hash_password(example_password), | ||
role=UserRole.CONTRIBUTOR, | ||
first_name="contributor", | ||
last_name="last", | ||
) | ||
db_session.add(user) | ||
db_session.commit() | ||
|
||
return user | ||
|
||
@pytest.fixture | ||
def access_token(client, example_user): | ||
|
@@ -91,6 +104,17 @@ def access_token(client, example_user): | |
assert res.status_code == 200 | ||
return res.json["access_token"] | ||
|
||
@pytest.fixture | ||
def contributor_access_token(client, contributor_user): | ||
res = client.post( | ||
"api/v1/auth/login", | ||
json={ | ||
"email": contributor_email, | ||
"password": example_password, | ||
}, | ||
) | ||
assert res.status_code == 200 | ||
return res.json["access_token"] | ||
|
||
@pytest.fixture | ||
def cli_runner(app): | ||
|
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