Skip to content

Commit

Permalink
Merge pull request #2220 from bcgov/gwells-2189-migrate-dependencies
Browse files Browse the repository at this point in the history
[CHANGE][GWELLS-2189] Add well signals tests
  • Loading branch information
fergmac authored Apr 25, 2024
2 parents bd7e0c7 + be6034f commit b7119d5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ test-vue-update:
vue-coverage:
docker exec -ti gwells-frontend-1 /bin/bash -c "cd /app/frontend/; npm run coverage:test"

TEST_PATH ?= "."

test-django:
docker exec -ti gwells-backend-1 /bin/bash -c "cd /app/backend/; python -m coverage run manage.py test --noinput"
docker exec -ti gwells-backend-1 /bin/bash -c "cd /app/backend/; python -m coverage run manage.py test ${TEST_PATH} --noinput"

django-coverage:
docker exec -ti gwells-backend-1 /bin/bash -c "cd /app/backend/; coverage report"
Expand Down
41 changes: 41 additions & 0 deletions app/backend/wells/tests/test_signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django.test import TestCase
from django.contrib.gis.geos import Point
from wells.models import Well
from wells.signals import update_utm

class TestSignals(TestCase):
def test_update_utm__no_geom__well_not_updated(self):
well = Well(geom=None)

update_utm(sender=None, instance=well)

self.assertEqual(well.utm_zone_code, None)
self.assertEqual(well.utm_easting, None)
self.assertEqual(well.utm_northing, None)

def test_update_utm__geom_longitude_below_valid_range__well_not_updated(self):
well = Well(geom="POINT(-181.00 49.26)")

update_utm(sender=None, instance=well)

self.assertEqual(well.utm_zone_code, None)
self.assertEqual(well.utm_easting, None)
self.assertEqual(well.utm_northing, None)

def test_update_utm__geom_longitude_above_valid_range__well_not_updated(self):
well = Well(geom="POINT(181.00 49.26)")

update_utm(sender=None, instance=well)

self.assertEqual(well.utm_zone_code, None)
self.assertEqual(well.utm_easting, None)
self.assertEqual(well.utm_northing, None)

def test_update_utm__geom_valid__well_updated(self):
well = Well(geom="POINT(-122.540000 49.260000)")

update_utm(sender=None, instance=well)

self.assertEqual(well.utm_zone_code, 10)
self.assertEqual(well.utm_easting, 533470)
self.assertEqual(well.utm_northing, 5456461)

0 comments on commit b7119d5

Please sign in to comment.