Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add RiskOfBiasScoreOverrideObject to admin (#374)
- gracefully handle case where the RiskOfBiasScoreOverrideObject.content_object is deleted in serializations - URL redirects to /404/ - text indicates the object is deleted - update admin for review of RiskOfBiasScoreOverrideObject - update docs for how to setup celery tasks - add method for finding orphaned RiskOfBiasScoreOverrideObject and optionally deleting them - added celery task to check periodically and Log findings (may automatically delete at some point)
- Loading branch information
1 parent
c5e6213
commit eed910c
Showing
9 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from textwrap import dedent | ||
|
||
import pytest | ||
from django.urls import reverse | ||
|
||
from hawc.apps.riskofbias.models import RiskOfBiasScoreOverrideObject | ||
|
||
|
||
@pytest.mark.django_db | ||
class TestRiskOfBiasScoreOverrideObject: | ||
def test_get_object_url(self): | ||
valid = RiskOfBiasScoreOverrideObject.objects.get(id=2) | ||
assert valid.get_object_url() == valid.content_object.get_absolute_url() | ||
|
||
invalid = RiskOfBiasScoreOverrideObject.objects.get(id=3) | ||
assert invalid.get_object_url() == reverse("404") | ||
|
||
def test_get_object_name(self): | ||
valid = RiskOfBiasScoreOverrideObject.objects.get(id=2) | ||
assert valid.get_object_name() == "sd rats" | ||
|
||
invalid = RiskOfBiasScoreOverrideObject.objects.get(id=3) | ||
assert "deleted" in invalid.get_object_name() | ||
|
||
def test_get_orphan_relations(self): | ||
actual = RiskOfBiasScoreOverrideObject.get_orphan_relations() | ||
expected = dedent( | ||
""" | ||
Found orphaned RiskOfBiasScoreOverrideObjects: | ||
id=3;score=16;obj_ct=49;obj_id=99999 | ||
""" | ||
).strip() | ||
assert actual == expected |