-
-
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.
Added Simple Get Route for Incidents
- Loading branch information
Showing
5 changed files
with
217 additions
and
47 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
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 |
---|---|---|
|
@@ -4,10 +4,11 @@ | |
from backend.auth import user_manager | ||
from backend.config import TestingConfig | ||
from backend.database import User, UserRole, db | ||
from backend.database import Partner, PartnerMember, MemberRole | ||
from backend.database import Partner, PartnerMember, MemberRole, Incident | ||
from datetime import datetime | ||
from pytest_postgresql.janitor import DatabaseJanitor | ||
from sqlalchemy import insert | ||
from typing import Any | ||
|
||
example_email = "[email protected]" | ||
admin_email = "[email protected]" | ||
|
@@ -81,6 +82,35 @@ def example_user(db_session): | |
return user | ||
|
||
|
||
@pytest.fixture # type: ignore | ||
def example_incidents(db_session: Any, example_partner: Partner): | ||
incidents = [ | ||
Incident( | ||
source_id=example_partner.id, | ||
date_record_created=datetime.now(), | ||
time_of_incident=datetime.now(), | ||
time_confidence=90, | ||
complaint_date=datetime.now().date(), | ||
closed_date=datetime.now().date(), | ||
location="Location 1", | ||
longitude=12.34, | ||
latitude=56.78, | ||
description="Description 1", | ||
stop_type="Stop Type 1", | ||
call_type="Call Type 1", | ||
has_attachments=True, | ||
from_report=True, | ||
was_victim_arrested=False, | ||
criminal_case_brought=True, | ||
) | ||
] | ||
for incident in incidents: | ||
db_session.add(incident) | ||
db_session.commit() | ||
|
||
return incidents | ||
|
||
|
||
@pytest.fixture | ||
def admin_user(db_session): | ||
user = User( | ||
|
@@ -102,17 +132,19 @@ def partner_admin(db_session, example_partner): | |
email=p_admin_email, | ||
password=user_manager.hash_password(example_password), | ||
role=UserRole.CONTRIBUTOR, # This is not a system admin, | ||
# so we can't use ADMIN here | ||
# so we can't use ADMIN here | ||
first_name="contributor", | ||
last_name="last", | ||
phone_number="(012) 345-6789", | ||
) | ||
db_session.add(user) | ||
db_session.commit() | ||
insert_statement = insert(PartnerMember).values( | ||
partner_id=example_partner.id, user_id=user.id, | ||
role=MemberRole.ADMIN, date_joined=datetime.now(), | ||
is_active=True | ||
partner_id=example_partner.id, | ||
user_id=user.id, | ||
role=MemberRole.ADMIN, | ||
date_joined=datetime.now(), | ||
is_active=True, | ||
) | ||
db_session.execute(insert_statement) | ||
db_session.commit() | ||
|
@@ -127,14 +159,16 @@ def partner_publisher(db_session, example_partner): | |
password=user_manager.hash_password(example_password), | ||
role=UserRole.CONTRIBUTOR, | ||
first_name="contributor", | ||
last_name="last" | ||
last_name="last", | ||
) | ||
db_session.add(user) | ||
db_session.commit() | ||
insert_statement = insert(PartnerMember).values( | ||
partner_id=example_partner.id, user_id=user.id, | ||
role=MemberRole.PUBLISHER, date_joined=datetime.now(), | ||
is_active=True | ||
partner_id=example_partner.id, | ||
user_id=user.id, | ||
role=MemberRole.PUBLISHER, | ||
date_joined=datetime.now(), | ||
is_active=True, | ||
) | ||
db_session.execute(insert_statement) | ||
db_session.commit() | ||
|
Oops, something went wrong.