-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(api) Pouvoir chercher les structures par SIREN #1074
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
|
@@ -238,6 +238,66 @@ def test_should_return_detailed_siae_object_to_authenticated_user(self): | |
self.assertTrue("sectors" in response.data) | ||
|
||
|
||
class SiaeRetrieveBySirenApiTest(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
SiaeFactory(name="Une structure", siret="12312312312345", department="38") | ||
SiaeFactory(name="Une autre structure", siret="22222222222222", department="69") | ||
SiaeFactory(name="Une autre structure avec le meme siret", siret="22222222222222", department="69") | ||
UserFactory(api_key="admin") | ||
|
||
def test_should_return_400_if_siren_malformed(self): | ||
# anonymous user | ||
for siren in ["123", "12312312312345"]: | ||
url = reverse("api:siae-retrieve-by-siren", args=[siren]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
def test_should_return_empty_list_if_siren_unknown(self): | ||
# anonymous user | ||
url = reverse("api:siae-retrieve-by-siren", args=["444444444"]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
# self.assertEqual(type(response.data), list) | ||
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. Tu as laissé des lignes commentées 😉 |
||
self.assertEqual(len(response.data), 0) | ||
|
||
def test_should_return_siae_list_if_siren_known(self): | ||
# anonymous user | ||
url = reverse("api:siae-retrieve-by-siren", args=["123123123"]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
# self.assertEqual(type(response.data), list) | ||
self.assertEqual(len(response.data), 1) | ||
self.assertEqual(response.data[0]["siret"], "12312312312345") | ||
self.assertEqual(response.data[0]["slug"], "une-structure-38") | ||
self.assertTrue("sectors" not in response.data) | ||
url = reverse("api:siae-retrieve-by-siren", args=["222222222"]) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
# self.assertEqual(type(response.data), list) | ||
self.assertEqual(len(response.data), 2) | ||
self.assertEqual(response.data[0]["siret"], "22222222222222") | ||
self.assertEqual(response.data[1]["siret"], "22222222222222") | ||
self.assertTrue("sectors" not in response.data[0]) | ||
# authenticated user | ||
url = reverse("api:siae-retrieve-by-siren", args=["123123123"]) + "?token=admin" | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
# self.assertEqual(type(response.data), list) | ||
self.assertEqual(len(response.data), 1) | ||
self.assertEqual(response.data[0]["siret"], "12312312312345") | ||
self.assertEqual(response.data[0]["slug"], "une-structure-38") | ||
self.assertTrue("sectors" in response.data[0]) | ||
url = reverse("api:siae-retrieve-by-siren", args=["222222222"]) + "?token=admin" | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
# self.assertEqual(type(response.data), list) | ||
self.assertEqual(len(response.data), 2) | ||
self.assertEqual(response.data[0]["siret"], "22222222222222") | ||
self.assertEqual(response.data[1]["siret"], "22222222222222") | ||
self.assertTrue("sectors" in response.data[0]) | ||
|
||
|
||
class SiaeRetrieveBySiretApiTest(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
|
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
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.
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.
J'aurai peut-être changé les 5 derniers chiffres pour avoir des SIRET différents sur le même SIREN. Je pense que c'est plus réaliste.
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.
je vais faire ca dans une petite PR séparée 👌
et améliorer un peu cet endpoint par siret