-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBC22-1890: Unit tests for current weather model
- Loading branch information
Showing
4 changed files
with
29 additions
and
10 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
23 changes: 23 additions & 0 deletions
23
src/backend/apps/weather/tests/test_current_weather_model.py
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,23 @@ | ||
from unittest.mock import patch | ||
|
||
from apps.shared.tests import BaseTest | ||
from apps.weather.models import BaseModel, CurrentWeather | ||
from apps.weather.serializers import CurrentWeatherSerializer | ||
|
||
|
||
def mocked_method(self): | ||
# Method to block the base model save function | ||
return True | ||
|
||
class TestCurrentWeatherModel(BaseTest): | ||
|
||
@patch.object(BaseModel, 'save', mocked_method) | ||
def test_model_save(self): | ||
current_weather_test = CurrentWeather( | ||
weather_station_name="Vancouver", | ||
location_latitude=58.66, | ||
location_longitude=-124.64, | ||
) | ||
current_weather_test.save(); | ||
|
||
assert(current_weather_test.location == "SRID=4326;POINT (58.66 -124.64)") |
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