-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-1374] SLC. Connect search & result page for name and address search with Backend API (integration) #483
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
Innavin369
merged 22 commits into
main
from
OSDEV-1374-slc-connect-search-and-result-page
Jan 21, 2025
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0adbc7a
WIP
roman-stolar c2bf1ee
Merge branch 'main' into OSDEV-1374-slc-connect-search-and-result-page
roman-stolar 72b7624
IN PROGRESS
roman-stolar ad88310
set up routing, added task description
b398777
rename vars,removed unnecessary logic, set max result limit,added tas…
aef17d8
corrected small issue
bf0cea7
Merge branch 'main' into OSDEV-1374-slc-connect-search-and-result-page
0d0ec29
delete redundant productionLocationsCount
23885ed
merged main
afbe99f
Merge branch 'main' into OSDEV-1374-slc-connect-search-and-result-page
b74e532
merge two similar functions to one makeGetProductionLocationsForPoten…
230fb92
added tests for Search Results page integratoin
f87083d
fixed linter
65fbe92
renamed vars
a51ef8e
fixed url for request
1786e67
renamed vars
064a350
Merge branch 'main' into OSDEV-1374-slc-connect-search-and-result-page
df06978
extend React tests for this flow
0fb6c15
added clearAllMocks and additional checks
8eafae2
renamed test regarding logic
7bc159e
Merge branch 'main' into OSDEV-1374-slc-connect-search-and-result-page
f2fd7ea
added test for routing
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 |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
|
|
||
| import unittest.mock | ||
| from rest_framework.test import APITestCase | ||
| from rest_framework import status | ||
|
|
||
| OPEN_SEARCH_SERVICE = "api.views.v1.production_locations.OpenSearchService" | ||
|
|
||
|
|
||
| class SearchResultsTest(APITestCase): | ||
| def setUp(self): | ||
| super().setUp() | ||
| self.name = 'CHANG+KNITTING+FACTORY' | ||
| self.address = 'TONGHU+ECONOMIC+DEVELOPMENT+ZONE,HUIZHOU%2C+CHINA' | ||
| self.county_code = 'CN' | ||
| self.name1 = 'test name' | ||
| self.address1 = 'test address' | ||
| self.county_code1 = 'AX' | ||
|
|
||
| self.search_mock = unittest.mock.patch(OPEN_SEARCH_SERVICE).start() | ||
| self.search_index_mock = self.search_mock.return_value.search_index | ||
| self.search_results_response_mock = { | ||
| "count": 2, | ||
| "data": [ | ||
| { | ||
| "sector": [ | ||
| "Apparel" | ||
| ], | ||
| "coordinates": { | ||
| "lat": 23.082231, | ||
| "lng": 114.196658 | ||
| }, | ||
| "os_id": "CN2025016GP2VEJ", | ||
| "country": { | ||
| "alpha_2": "CN", | ||
| "alpha_3": "CHN", | ||
| "name": "China", | ||
| "numeric": "156" | ||
| }, | ||
| "claim_status": "unclaimed", | ||
| "address": "KIU HING ROAD, 2-12 TONGHU, CHINA", | ||
| "name": "XIN CHANG CHANG KNITTING FACTORY" | ||
| }, | ||
| { | ||
| "sector": [ | ||
| "Apparel" | ||
| ], | ||
| "coordinates": { | ||
| "lat": 30.607581, | ||
| "lng": 120.55107 | ||
| }, | ||
| "os_id": "CN2025016RHMQVG", | ||
| "country": { | ||
| "alpha_2": "CN", | ||
| "alpha_3": "CHN", | ||
| "name": "China", | ||
| "numeric": "156" | ||
| }, | ||
| "claim_status": "unclaimed", | ||
| "address": "No. 2 Industrial Area Economic, Zhejiang Province", | ||
| "name": "Tongxiang Miracle Knitting Factory Co. Ltd." | ||
| } | ||
| ], | ||
| } | ||
|
|
||
| def get_url(self, name, address, county_code): | ||
| base_url = "/api/v1/production-locations/" | ||
| query_string = f"?name={name}&address={address}&country={county_code}" | ||
| return f"{base_url}?{query_string}" | ||
|
|
||
| def test_receive_search_results_data(self): | ||
| self.search_index_mock.return_value = self.search_results_response_mock | ||
| api_res = self.client.get( | ||
| self.get_url(self.name, self.address, self.county_code)) | ||
| self.assertEqual(api_res.status_code, status.HTTP_200_OK) | ||
| self.assertEqual(api_res.data, self.search_results_response_mock) | ||
| self.assertEqual(len(api_res.data.get("data")), | ||
| api_res.data.get("count")) | ||
|
|
||
| def test_get_search_results_not_found(self): | ||
| self.search_index_mock.return_value = {"data": [], "count": 0} | ||
| api_res = self.client.get( | ||
| self.get_url(self.name1, self.address1, self.county_code1)) | ||
| self.assertEqual(api_res.status_code, status.HTTP_200_OK) | ||
| self.assertEqual(len(api_res.data.get("data")), 0) | ||
| self.assertEqual(api_res.data.get("count"), 0) | ||
Innavin369 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.