Skip to content

Commit

Permalink
FFT-50 Improve local env test data and DX
Browse files Browse the repository at this point in the history
  • Loading branch information
SamDudley committed Oct 2, 2024
1 parent 31e8d4d commit 811900b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ALLOWED_HOSTS="*"
DEBUG=True
DISABLE_COLLECTSTATIC="0"
DATABASE_URL=psql://postgres:postgres@db:5432/fido
REDIS_ENDPOINT=redis://redis:6379
CACHE_ENDPOINT=redis://redis:6379

# Authbroker
AUTHBROKER_CLIENT_ID=copy-from-dev-environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: make black-check

- name: Run tests
run: make pytest
run: make pytest-ci

- name: Bring up chrome
run: docker compose up -d chrome
Expand Down
2 changes: 2 additions & 0 deletions config/settings/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
]

ASYNC_FILE_UPLOAD = False

AXES_ENABLED = False
2 changes: 2 additions & 0 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
]

ASYNC_FILE_UPLOAD = False

AXES_ENABLED = False
1 change: 1 addition & 0 deletions core/management/commands/create_stub_forecast_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_monthly_figures():
)
budget_amount += 1

# archive the first 2 months (apr, may)
for period_id in range(1, 3):
end_of_month_archive(period_id)
actual = FinancialPeriod.objects.get(financial_period_code=period_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def handle(self, *args, **options):
action = create_future_year_figure
msg = "created"

# if 2020 is the current financial year then this will be 2021, 2022, 2023
for interval in range(1, 4):
year_obj = get_financial_year_obj(financial_year + interval)

Expand Down
4 changes: 4 additions & 0 deletions end_of_month/end_of_month_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def get_end_of_month(period_code):


def end_of_month_archive(period_id, used_for_current_month=False):
"""Archive a financial period at the end of the month.
This is a top-level business logic unit and belongs in a service.
"""
end_of_month_info = get_end_of_month(period_id)

current_year = get_current_financial_year()
Expand Down
12 changes: 9 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ manage = python manage.py

create-stub-data: # Create stub data for testing
make migrate
$(web) $(manage) set_current_year
$(web) $(manage) create_stub_data All
$(web) $(manage) create_stub_forecast_data
$(web) $(manage) create_stub_future_forecast_data
$(web) $(manage) create_data_lake_stub_data
$(web) $(manage) create_test_user
$(web) $(manage) create_test_user --password=password

setup: # Set up the project from scratch
make down
Expand Down Expand Up @@ -73,8 +74,11 @@ requirements: # Generate requirements.txt
test: # Run tests
$(web) $(manage) test $(test)

pytest: # Run pytest ignoring; node_modules, front_end, features, staticfiles.
$(web) pytest --ignore=node_modules --ignore=front_end --ignore=features --ignore=staticfiles --random-order -n 4 -v
pytest: # Run pytest
$(web) pytest $(test)

pytest-ci: # Run pytest with settings for CI
$(web) pytest --random-order -n 4 -v

superuser: # Create superuser
$(web) $(manage) createsuperuser
Expand Down Expand Up @@ -123,6 +127,8 @@ db-reset: # Reset the database
docker compose rm -f db
docker compose up -d db

db-init: create-stub-data # Initialise the database

db-shell: # Open the database container postgres shell
$(db) psql -U postgres

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ extend-exclude = ["config/*", "features/*", "migrations", "manage.py"]
select = ["E", "F", "B"]
# Never enforce `E501` (line length violations).
ignore = ["E501", "B904"]

[tool.pytest.ini_options]
minversion = "7.0"
addopts = "--ignore=front_end --ignore=features --ignore=staticfiles --ds=config.settings.ci --reuse-db"
python_files = ["test_*.py", "*_test.py", "tests.py"]
filterwarnings = ["ignore::DeprecationWarning"]
4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

0 comments on commit 811900b

Please sign in to comment.