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

Commit beb4451

Browse files
authored
Create separate seed file for system testing (#389)
This seeds the db with only an admin user for system testing. This should also speed up the system tests on the CI.
1 parent 30c8943 commit beb4451

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.github/workflows/system_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Seed db
5151
run: |
5252
pipenv run flask db create
53-
pipenv run flask db seed
53+
pipenv run flask db minimal_seed
5454
5555
- name: Start Server
5656
run: pipenv run flask run &

data/seed.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,15 @@
3030

3131

3232
class Seed:
33+
def minimal_data(self):
34+
self.create_admin()
35+
3336
def data(self):
37+
print("Seeding the db... This may take a few minutes.")
3438
self.faker = Faker()
3539
self.rand = random.Random()
3640

37-
Admin.create(
38-
schema=UserSchema,
39-
payload={
40-
"email": "user1@dwellingly.org",
41-
"role": RoleEnum.ADMIN.value,
42-
"firstName": "user1",
43-
"lastName": "tester",
44-
"password": "1234",
45-
"phone": "555-555-5555",
46-
},
47-
)
41+
self.create_admin()
4842

4943
# Create some admins
5044
for _ in range(7):
@@ -239,6 +233,19 @@ def data(self):
239233
print("\n")
240234
print("#####################################")
241235

236+
def create_admin(self):
237+
Admin.create(
238+
schema=UserSchema,
239+
payload={
240+
"email": "user1@dwellingly.org",
241+
"role": RoleEnum.ADMIN.value,
242+
"firstName": "user1",
243+
"lastName": "tester",
244+
"password": "1234",
245+
"phone": "555-555-5555",
246+
},
247+
)
248+
242249
def user_attributes(self, role=None, archived=False):
243250
attrs = {
244251
"email": self.faker.unique.email(),

manage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def seed():
1717
Seed().data()
1818

1919

20+
@dbsetup.cli.command("minimal_seed")
21+
def minimal_seed():
22+
from data.seed import Seed
23+
24+
Seed().minimal_data()
25+
26+
2027
@dbsetup.cli.command("create")
2128
def create():
2229
"""Creates database tables"""

0 commit comments

Comments
 (0)