Skip to content

Commit 312d006

Browse files
committed
Empty taxon should be classified as 'Off-topic'
1 parent 0bcd7da commit 312d006

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

api/tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from rest_framework.authtoken.models import Token
88

99
from django.core.files.uploadedfile import SimpleUploadedFile
10+
from django.core.management import call_command
1011
from django.contrib.auth import get_user_model
1112
from django.contrib.gis.geos import Polygon, MultiPolygon
1213
from django.utils import timezone
@@ -26,6 +27,11 @@
2627
TEST_DATA_PATH = Path(Path(__file__).parent.absolute(), "test_data/")
2728

2829

30+
@pytest.fixture
31+
def taxa(db):
32+
call_command('loaddata', '/app/tigacrafting/fixtures/taxon.json')
33+
call_command('loaddata', '/app/tigaserver_app/fixtures/categories.json')
34+
2935
@pytest.fixture
3036
def user_password():
3137
return "testpassword123_tmp"
@@ -240,7 +246,7 @@ def test_non_image_path():
240246

241247
@pytest.fixture
242248
def taxon_root():
243-
return Taxon.add_root(
249+
return Taxon.get_root() or Taxon.add_root(
244250
rank=Taxon.TaxonomicRank.CLASS,
245251
name="Insecta",
246252
common_name=""

api/tests/test_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ def test_device_without_device_id_is_updated_on_create(self, app_user):
676676
assert Device.objects.filter(user=app_user).count() == 1
677677

678678
@pytest.mark.django_db
679+
@pytest.mark.usefixtures("taxa")
679680
class TestIdentificationTaskAnnotationsApi:
680681
@pytest.fixture
681682
def endpoint(self, identification_task):

tigacrafting/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ def on_taxon_change(self):
12041204

12051205
if not taxon:
12061206
# Set as 'Off-topic'. This is not a mosquito observation.
1207-
self.category = Categories.objects.filter(pk=9).first()
1207+
self.category = Categories.objects.filter(pk=1).first()
12081208
return
12091209

12101210
_taxon_content_object = taxon.content_object

0 commit comments

Comments
 (0)