Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Aug 22, 2024
1 parent 3c0de41 commit 19b55c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ def add_created_date(self) -> None:
when="environment_document_updated",
is_now=True,
)
def process_environment_update(self):
def process_environment_update(self) -> None:
if not self.project:
return

from environments.models import Environment
from environments.tasks import process_environment_update

Expand Down
13 changes: 13 additions & 0 deletions api/tests/unit/audit/test_unit_audit_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from pytest_mock import MockerFixture

from audit.models import AuditLog
Expand Down Expand Up @@ -228,3 +229,15 @@ def test_creating_audit_logs_for_change_request_does_not_trigger_process_environ
# Then
process_environment_update.delay.assert_not_called()
assert audit_log.created_date != environment.updated_at


@pytest.mark.django_db
def test_audit_log__organisation__empty_instance__return_expected() -> None:
# Given
audit_log = AuditLog.objects.create()

# When
organisation = audit_log.organisation

# Then
assert organisation is None

0 comments on commit 19b55c0

Please sign in to comment.