-
Notifications
You must be signed in to change notification settings - Fork 40
OpenConceptLab/ocl_issues#2485 | API to get project configurations #862
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ def setUp(self): | |
|
|
||
| self.file = SimpleUploadedFile('input.csv', b'content', "application/csv") | ||
|
|
||
|
|
||
| class MapProjectListViewTest(MapProjectAbstractViewTest): | ||
| @patch('core.services.storages.cloud.aws.S3.upload') | ||
| def test_post(self, upload_mock): | ||
|
|
@@ -120,3 +121,35 @@ def test_put(self, upload_mock): | |
| self.assertEqual(len(response.data['columns']), 1) | ||
| upload_mock.assert_called_once_with( | ||
| key=f"map_projects/{response.data['id']}/input.csv", file_content=ANY) | ||
|
|
||
|
|
||
| class MapProjectConfigurationsViewTest(MapProjectAbstractViewTest): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test asserts that included fields are correct, but doesn't assert the ticket's actual contract: that excluded fields are absent. Please add assertions that the response does NOT contain Also missing:
|
||
| def test_get(self): | ||
| project = MapProjectFactory( | ||
| organization=self.org, | ||
| algorithms=[{'name': 'exact-match', 'enabled': True}], | ||
| encoder_model='snowflake-arctic-embed-l-v2.0', | ||
| filters={'retired': False, 'class': ['LabSet']}, | ||
| include_retired=True, | ||
| lookup_config={'concepts': {'limit': 20}}, | ||
| score_configuration={'recommended': 95, 'available': 75}, | ||
| target_repo_url='/orgs/CIEL/sources/CIEL/', | ||
| ) | ||
| project.save() | ||
|
|
||
| response = self.client.get( | ||
| f'/orgs/CIEL/map-projects/{project.id}/configurations/', | ||
| HTTP_AUTHORIZATION='Token ' + self.user.get_token(), | ||
| ) | ||
|
|
||
| self.assertEqual(response.status_code, 200) | ||
| self.assertEqual(response.data['id'], project.id) | ||
| self.assertIsNotNone(response.data['id']) | ||
| self.assertEqual(response.data['url'], f'/orgs/CIEL/map-projects/{project.id}/') | ||
| self.assertEqual(response.data['algorithms'], [{'name': 'exact-match', 'enabled': True}]) | ||
| self.assertEqual(response.data['encoder_model'], 'snowflake-arctic-embed-l-v2.0') | ||
| self.assertEqual(response.data['filters'], {'retired': False, 'class': ['LabSet']}) | ||
| self.assertTrue(response.data['include_retired']) | ||
| self.assertEqual(response.data['lookup_config'], {'concepts': {'limit': 20}}) | ||
| self.assertEqual(response.data['score_configuration'], {'recommended': 95, 'available': 75}) | ||
| self.assertEqual(response.data['target_repo_url'], '/orgs/CIEL/sources/CIEL/') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once
CONFIGURATION_FIELDSlives on the model (see top-level review comment), replace the hardcoded list here with['id', 'url'] + MapProject.CONFIGURATION_FIELDS. Also worth a one-line docstring on the class stating the rule (e.g. "Fields that define how a project matches — excluding identity, results, logs, and audit metadata. Used by the copy-project flow.") so the contract is discoverable.Two field-scope questions worth confirming explicitly (in code or PR description):
descriptionis inMapProjectCreateUpdateSerializerbut excluded here — copy won't carry the description forward. Intentional? (Arguably correct since the description likely refers to the original project, but worth being deliberate.)public_accessis in the base serializer but excluded here — the copied project gets default access rather than inheriting. Likely correct, but same point: worth being deliberate.