-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-2329] Show MIT Living Wage and WageIndicator data in GET v1/production-locations #858
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
Merged
VadimKovalenkoSNF
merged 18 commits into
main
from
OSDEV-2329-mit-living-wage-production-locations
Jan 30, 2026
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5ea3e22
Show mit fields in v1 (partial imple)
VadimKovalenkoSNF 7b70958
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 58c4f63
Minor refactoring
VadimKovalenkoSNF d4d4f88
Refactor __get_partner_fields method
VadimKovalenkoSNF 34eccae
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 4fc446f
Fix unit tests
VadimKovalenkoSNF e3173b7
Minor fix
VadimKovalenkoSNF 026614a
Apply rich living wage output
VadimKovalenkoSNF c57aea1
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF d78d659
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 7f19bf6
Add release notes
VadimKovalenkoSNF 40819ff
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 3b58dd5
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 305e36e
Upd living wage response format
VadimKovalenkoSNF f629b79
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF e28ebfa
Minor restructuring of partner field methods
VadimKovalenkoSNF c615181
Merge branch 'main' into OSDEV-2329-mit-living-wage-production-locations
VadimKovalenkoSNF 6c4e5be
Update response payload
VadimKovalenkoSNF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,8 +1,19 @@ | ||
| import unittest.mock | ||
| from django.contrib.gis.geos import Point, MultiPolygon | ||
| from django.core.cache import cache | ||
| from rest_framework.test import APITestCase | ||
| from rest_framework import status | ||
| from api.views.v1.response_mappings.production_locations_response \ | ||
| import ProductionLocationsResponseMapping | ||
| from api.models.partner_field import PartnerField | ||
| from api.models.contributor.contributor import Contributor | ||
| from api.models.facility.facility import Facility | ||
| from api.models.facility.facility_list import FacilityList | ||
| from api.models.facility.facility_list_item import FacilityListItem | ||
| from api.models.source import Source | ||
| from api.models.user import User | ||
| from api.models.us_county_tigerline import USCountyTigerline | ||
| from api.models.wage_indicator_country_data import WageIndicatorCountryData | ||
|
|
||
|
|
||
| OPEN_SEARCH_SERVICE = "api.views.v1.production_locations.OpenSearchService" | ||
|
|
@@ -132,3 +143,151 @@ def test_single_production_location_response_mapping(self): | |
| query_body["_source"], | ||
| ProductionLocationsResponseMapping.PRODUCTION_LOCATION_BY_OS_ID, | ||
| ) | ||
|
|
||
| def _create_facility_with_partner_data(self): | ||
| cache.clear() | ||
| user = User.objects.create(email="[email protected]") | ||
| contributor = Contributor.objects.create( | ||
| admin=user, | ||
| name="Test Contributor", | ||
| description="", | ||
| website="", | ||
| contrib_type=Contributor.OTHER_CONTRIB_TYPE, | ||
| ) | ||
|
|
||
| wage_indicator_field, _ = PartnerField.objects.get_or_create( | ||
| name="wage_indicator", | ||
| defaults={ | ||
| "type": PartnerField.OBJECT, | ||
| "system_field": True, | ||
| "base_url": "https://wageindicator.example/", | ||
| } | ||
| ) | ||
| mit_living_wage_field, _ = PartnerField.objects.get_or_create( | ||
| name="mit_living_wage", | ||
| defaults={ | ||
| "type": PartnerField.OBJECT, | ||
| "system_field": True, | ||
| "base_url": "https://livingwage.mit.edu/counties/", | ||
| } | ||
| ) | ||
|
|
||
| contributor.partner_fields.add( | ||
| wage_indicator_field, | ||
| mit_living_wage_field, | ||
| ) | ||
|
|
||
| facility_list = FacilityList.objects.create( | ||
| name="Test List", | ||
| file_name="test.csv", | ||
| header="name,address,country", | ||
| ) | ||
| source = Source.objects.create( | ||
| source_type=Source.LIST, | ||
| facility_list=facility_list, | ||
| contributor=contributor, | ||
| ) | ||
| facility_list_item = FacilityListItem.objects.create( | ||
| name="Test Facility", | ||
| address="123 Example St", | ||
| country_code="US", | ||
| sector=["Apparel"], | ||
| row_index=0, | ||
| status=FacilityListItem.CONFIRMED_MATCH, | ||
| source=source, | ||
| raw_data="Test Facility,123 Example St,US", | ||
| raw_header="name,address,country", | ||
| raw_json={}, | ||
| processing_results=[], | ||
| ) | ||
|
|
||
| location = Point(-73.935242, 40.73061, srid=4326) | ||
| facility = Facility.objects.create( | ||
| id=self.os_id, | ||
| name="Test Facility", | ||
| address="123 Example St", | ||
| country_code="US", | ||
| location=location, | ||
| created_from=facility_list_item, | ||
| ) | ||
|
|
||
| WageIndicatorCountryData.objects.update_or_create( | ||
| country_code=facility.country_code, | ||
| defaults={ | ||
| "living_wage_link_national": ( | ||
| "https://paywizard.org/salary/living-wages" | ||
| ), | ||
| "minimum_wage_link_english": ( | ||
| "https://wageindicator.org/salary/minimum-wage/" | ||
| "united-states-of-america" | ||
| ), | ||
| "minimum_wage_link_national": ( | ||
| "https://paywizard.org/salary/minimum-wage" | ||
| ), | ||
| }, | ||
| ) | ||
|
|
||
| point_5070 = location.transform(5070, clone=True) | ||
| county_geometry = point_5070.buffer(1) | ||
| if county_geometry.geom_type != "MultiPolygon": | ||
| county_geometry = MultiPolygon(county_geometry) | ||
|
|
||
| USCountyTigerline.objects.create( | ||
| geoid="12345", | ||
| name="Test County", | ||
| geometry=county_geometry, | ||
| ) | ||
|
|
||
| return facility | ||
|
|
||
| def test_get_single_production_location_includes_partner_fields(self): | ||
| facility = self._create_facility_with_partner_data() | ||
|
|
||
| self.search_index_mock.return_value = { | ||
| "count": 1, | ||
| "data": [ | ||
| { | ||
| "os_id": facility.id, | ||
| "name": "location1", | ||
| } | ||
| ], | ||
| } | ||
|
|
||
| url = f"/api/v1/production-locations/{facility.id}/" | ||
| api_res = self.client.get(url) | ||
|
|
||
| self.assertEqual(api_res.status_code, status.HTTP_200_OK) | ||
| self.assertIn("wage_indicator", api_res.data) | ||
| self.assertIn("mit_living_wage", api_res.data) | ||
|
|
||
| wage_indicator = api_res.data["wage_indicator"] | ||
| mit_living_wage = api_res.data["mit_living_wage"] | ||
|
|
||
| self.assertIsInstance(wage_indicator, list) | ||
| self.assertIsInstance(mit_living_wage, list) | ||
| self.assertGreaterEqual(len(wage_indicator), 1) | ||
| self.assertGreaterEqual(len(mit_living_wage), 1) | ||
|
|
||
| wi_entry = wage_indicator[0] | ||
| mit_entry = mit_living_wage[0] | ||
|
|
||
| self.assertEqual( | ||
| wi_entry["value"]["raw_values"]["living_wage_link_national"], | ||
| "https://paywizard.org/salary/living-wages", | ||
| ) | ||
| self.assertEqual( | ||
| wi_entry["value"]["raw_values"]["minimum_wage_link_english"], | ||
| "https://wageindicator.org/salary/minimum-wage/" | ||
| "united-states-of-america", | ||
| ) | ||
| self.assertEqual( | ||
| wi_entry["value"]["raw_values"]["minimum_wage_link_national"], | ||
| "https://paywizard.org/salary/minimum-wage", | ||
| ) | ||
| self.assertEqual(wi_entry["field_name"], "wage_indicator") | ||
|
|
||
| self.assertEqual( | ||
| mit_entry["value"]["raw_values"]["county_id"], | ||
| "12345", | ||
| ) | ||
| self.assertEqual(mit_entry["field_name"], "mit_living_wage") | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.