Skip to content
This repository was archived by the owner on Oct 2, 2025. It is now read-only.

Commit 7a290b7

Browse files
committed
Add db seed fixture for auth_user
1 parent 142a126 commit 7a290b7

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.env.testing

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ TIME_ZONE='Europe/London'
66
APP_ENV=testing
77
SIGNING_KEY=2de5c7b55db0e2bcbaac7a135e7b0cf340da8dba93f8c6d4f5ef0934887c834b
88
MARIADB_DATABASE=boilerplate
9-
MARIADB_USER=root
10-
MARIADB_PASSWORD=
9+
MARIADB_USER=user
10+
MARIADB_PASSWORD=secret
1111
MARIADB_HOST=localhost
1212
MARIADB_PORT=3306
1313
EMAIL_HOST=mailhog

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ jobs:
5555
run: sed -i "s/3306/${{ job.services.mysql.ports['3306'] }}/g" .env.testing
5656
- name: Create environment file
5757
run: cp .env.testing .env
58-
- name: Run Tests
58+
- name: Create database tables
5959
run: |
60-
python ${{ env.django_test_args }} manage.py test
60+
# mkdir mynewapp/migrations
61+
# touch mynewapp/migrations/__init__.py
62+
# python manage.py makemigrations
63+
python manage.py migrate
64+
- name: Create super user
65+
run: python manage.py loaddata app/fixtures/auth_user
66+
- name: Run Tests
67+
run: python ${{ env.django_test_args }} manage.py test

app/fixtures/auth_user.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"model": "auth.user",
4+
"pk": 1,
5+
"fields": {
6+
"password": "pbkdf2_sha256$320000$qJzyiNcYZBbXcJyFqwaCjG$3M3xtHf+9SR4pAZ9zT7xPCvxB3vBEjERpDzrS4OSxjg=",
7+
"last_login": null,
8+
"is_superuser": true,
9+
"username": "admin_user",
10+
"first_name": "",
11+
"last_name": "",
12+
"email": "admin@django-app.com",
13+
"is_staff": true,
14+
"is_active": true,
15+
"date_joined": "2023-08-13T12:19:09.380Z",
16+
"groups": [],
17+
"user_permissions": []
18+
}
19+
}
20+
]

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ With docker support.
44

55
* [Installation](#installation)
66

7+
* [Add testing seed data](#add-testing-seed-data)
8+
79
* [Usage](#usage)
810

911
* [Using Docker](#using-docker)
@@ -33,6 +35,16 @@ pip install virtualenv && \
3335
source env/bin/activate
3436
```
3537

38+
##### Add testing seed data
39+
40+
Example:
41+
42+
Load data [auth_user.json](https://github.com/kkamara/python-react-boilerplate/blob/main/app/fixtures/auth_user.json) into database.
43+
44+
```bash
45+
python manage.py loaddata app/fixtures/auth_user
46+
```
47+
3648
## Usage
3749

3850
```bash

0 commit comments

Comments
 (0)