-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2220 from bcgov/gwells-2189-migrate-dependencies
[CHANGE][GWELLS-2189] Add well signals tests
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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
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) |