Skip to content
This repository was archived by the owner on Dec 19, 2021. It is now read-only.

Commit 463cdaa

Browse files
committed
horizon
1 parent 8180780 commit 463cdaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+73
-107
lines changed

.github/workflows/pytest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
- name: Create db
4848
run: createdb dwellingly_test
4949

50+
- name: Seed Test
51+
run: pipenv run flask db minimal_seed
52+
5053
- name: Test
5154
run: |
5255
pipenv run pytest

conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,9 @@ def _pm_header(pm=None):
7070

7171

7272
@pytest.fixture(autouse=True)
73-
def reset_db():
73+
def app_context(app):
7474
Seed().destroy_all()
7575

76-
@pytest.fixture(autouse=True)
77-
def empty_test_db(app):
78-
pass
79-
8076
# ------------- NON-FIXTURE FUNCTIONS --------------------
8177
def has_valid_headers(response):
8278
if response.content_type != "application/json":

data/seed.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,18 @@ def create_property_manager(self, payload):
292292
def destroy_all(self):
293293
db.session.execute(
294294
"""
295-
do
295+
DO
296296
$$
297-
declare
298-
l_stmt text;
299-
begin
300-
select 'truncate ' || string_agg(format('%I.%I', schemaname, tablename), ',')
301-
into l_stmt
302-
from pg_tables
303-
where schemaname in ('public');
304-
305-
execute l_stmt;
306-
end;
297+
DECLARE
298+
stmt text;
299+
BEGIN
300+
SELECT 'TRUNCATE ' || string_agg(format('%I.%I', schemaname, tablename), ',') || ' CASCADE'
301+
INTO stmt
302+
FROM pg_tables
303+
WHERE schemaname in ('public');
304+
305+
EXECUTE stmt;
306+
END;
307307
$$
308-
"""
308+
"""
309309
)

tests/authorizations/test_emergency_contact_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44

5-
@pytest.mark.usefixtures("client_class", "empty_test_db")
5+
@pytest.mark.usefixtures("client_class")
66
class TestEmergenyContactsAuthorizations:
77
def setup(self):
88
self.endpoint = "/api/emergencycontacts"

tests/authorizations/test_lease_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44

5-
@pytest.mark.usefixtures("client_class", "empty_test_db")
5+
@pytest.mark.usefixtures("client_class")
66
class TestLeaseAuthorizations:
77
def valid_payload(self, tenant, lease):
88
return {"tenantID": tenant.id, **lease}

tests/authorizations/test_property_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33

4-
@pytest.mark.usefixtures("client_class", "empty_test_db")
4+
@pytest.mark.usefixtures("client_class")
55
class TestPropertyAuthorizations:
66
def test_post_property(self, property_attributes):
77
property_attrs = property_attributes()

tests/authorizations/test_staff_tenant_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33

4-
@pytest.mark.usefixtures("client_class", "empty_test_db")
4+
@pytest.mark.usefixtures("client_class")
55
class TestStaffTenantAuthorizations:
66
def setup(self):
77
self.endpoint = "/api/staff-tenants"

tests/authorizations/test_tenant_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from conftest import is_valid
33

44

5-
@pytest.mark.usefixtures("client_class", "empty_test_db")
5+
@pytest.mark.usefixtures("client_class")
66
class TestTenantAuthorization:
77
def setup(self):
88
self.endpoint = "/api/tenants"

tests/authorizations/test_ticket_authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from conftest import is_valid
33

44

5-
@pytest.mark.usefixtures("empty_test_db", "client_class")
5+
@pytest.mark.usefixtures("client_class")
66
class TestTicketAuthorization:
77
def setup(self):
88
self.endpoint = "/api/tickets"

tests/authorizations/test_user_authentication.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from flask_jwt_extended import create_access_token, create_refresh_token
55

66

7-
@pytest.mark.usefixtures("client_class", "empty_test_db")
7+
@pytest.mark.usefixtures("client_class")
88
class TestUserAuthorization:
99
def test_user_auth(self, create_admin_user):
1010
password = "strongestpasswordever"
@@ -63,7 +63,7 @@ def test_get_user(self, pm_header):
6363
assert is_valid(unauthorized_user_response, 401)
6464

6565

66-
@pytest.mark.usefixtures("client_class", "empty_test_db")
66+
@pytest.mark.usefixtures("client_class")
6767
class TestUserDeleteAuthorization:
6868
def test_admin_is_authorized(self, admin_header, create_user):
6969
response = self.client.delete(
@@ -84,7 +84,7 @@ def test_pm_is_not_authorized(self, pm_header, create_user):
8484
assert response.status_code == 401
8585

8686

87-
@pytest.mark.usefixtures("client_class", "empty_test_db")
87+
@pytest.mark.usefixtures("client_class")
8888
class TestUserPatchAuthorization:
8989
def test_auth_token_is_required(self):
9090
response = self.client.patch("api/user/5", json={})
@@ -127,7 +127,7 @@ def test_pm_is_authorized_to_update_themselves(
127127
assert response == 200
128128

129129

130-
@pytest.mark.usefixtures("client_class", "empty_test_db")
130+
@pytest.mark.usefixtures("client_class")
131131
class TestUserLogic:
132132
# TODO: This doesn't belong in auth tests
133133
def test_password(self, header, create_user, faker):

0 commit comments

Comments
 (0)