Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev into master #2714

Merged
merged 8 commits into from
Oct 10, 2024
12 changes: 12 additions & 0 deletions anyway/views/news_flash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,19 @@ def update_news_flash_qualifying(id):

newsflash_location_qualification = request.values.get("newsflash_location_qualification")
road_segment_id = request.values.get("road_segment_id")
if road_segment_id:
if road_segment_id.isdigit():
road_segment_id = int(road_segment_id)
else:
logging.error("road_segment_id is not a number")
return return_json_error(Es.BR_BAD_FIELD)
road1 = request.values.get("road1")
if road1:
if road1.isdigit():
road1 = int(road1)
else:
logging.error("road1 is not a number")
return return_json_error(Es.BR_BAD_FIELD)
yishuv_name = request.values.get("yishuv_name")
street1_hebrew = request.values.get("street1_hebrew")
newsflash_location_qualification = QUALIFICATION_TO_ENUM_VALUE[newsflash_location_qualification]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_news_flash_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_add_location_qualifiction_history(self, can, current_user, get_current_
with patch("anyway.views.news_flash.api.db", db_mock):
with patch("anyway.app_and_db.db", db_mock):
mock_request = unittest.mock.MagicMock()
values = {"newsflash_location_qualification": "manual", "road_segment_id": 100, "road1": 1}
values = {"newsflash_location_qualification": "manual", "road_segment_id": "100", "road1": "1"}
mock_request.values.get = lambda key: values.get(key)
with patch("anyway.views.news_flash.api.request", mock_request):
id = self.session.query(NewsFlash).all()[0].id
Expand All @@ -106,7 +106,7 @@ def test_add_location_qualifiction_history(self, can, current_user, get_current_
saved_location = json.loads(location_verifiction_history["location_after_change"])
saved_road_segment_id = saved_location["road_segment_id"]
saved_road_num = saved_location["road1"]
self.assertEqual(saved_road_segment_id, values["road_segment_id"])
self.assertEqual(saved_road_segment_id, int(values["road_segment_id"]))
self.assertEqual(saved_road_num, float(values["road1"]))
self.assertEqual(
values["newsflash_location_qualification"],
Expand Down Expand Up @@ -135,7 +135,7 @@ def _test_update_news_flash_qualifying_manual_with_location(self):
db_mock = unittest.mock.MagicMock()
db_mock.session = self.session
mock_request = unittest.mock.MagicMock()
values = {"newsflash_location_qualification": "manual", "road_segment_id": 100, "road1": 1}
values = {"newsflash_location_qualification": "manual", "road_segment_id": "100", "road1": "1"}
mock_request.values.get = lambda key: values.get(key)
road_segment = RoadSegments(
segment_id=100,
Expand Down Expand Up @@ -170,7 +170,7 @@ def _test_update_news_flash_qualifying_not_manual_with_location(self):
also a new location
"""
mock_request = unittest.mock.MagicMock()
values = {"newsflash_location_qualification": "rejected", "road_segment_name": "road", "road1": 1}
values = {"newsflash_location_qualification": "rejected", "road_segment_name": "road", "road1": "1"}
mock_request.values.get = lambda key: values.get(key)
with patch("anyway.views.news_flash.api.request", mock_request):
id = self.session.query(NewsFlash).all()[0].id
Expand Down
Loading