-
Notifications
You must be signed in to change notification settings - Fork 50
Handle empty data in system info during setup #8415
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f775b40
Feat: Add a setup completed check in system info request def
CarolineDenis fe0f1f5
Fix: Handle missing stats in the frontend
CarolineDenis 2f31f4b
Fix: Handle typescript type null
CarolineDenis 8229d6c
Fix: Add setup_complete to frontend type
CarolineDenis b808eeb
Fix: Handle null type
CarolineDenis e9bdfc5
Fix: Handle inexisting resources
CarolineDenis 6b57a22
Test: Add backend system info test
CarolineDenis 020410e
Test: Update frontend tests
CarolineDenis 0decb0a
Test: Update static file
CarolineDenis 1a1d212
Fix: Restrict the exception handler to the expected missing-collectio…
CarolineDenis 8cfef26
Fix: Do not show a version mismatch before setup completes
CarolineDenis b6c9475
Fix: Block tree creation when discipline is empty
CarolineDenis 4e3ae94
Lint code with ESLint and Prettier
CarolineDenis 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import json | ||
| from unittest.mock import patch | ||
|
|
||
| from django.test import Client | ||
|
|
||
| from specifyweb.specify.models import Spversion | ||
| from specifyweb.specify.tests.test_api import ApiTests | ||
|
|
||
|
|
||
| class TestSystemInfo(ApiTests): | ||
| def test_system_info_during_guided_setup_returns_safe_payload(self): | ||
| c = Client() | ||
| c.force_login(self.specifyuser) | ||
| c.cookies['collection'] = str(self.collection.id) | ||
|
|
||
| with patch('specifyweb.backend.context.views.is_guided_setup_complete', return_value=False): | ||
| response = c.get('/context/system_info.json') | ||
|
|
||
| self._assertStatusCodeEqual(response, 200) | ||
| payload = json.loads(response.content.decode()) | ||
|
|
||
| self.assertFalse(payload['setup_complete']) | ||
| self.assertIsNone(payload['database_version']) | ||
| self.assertIsNone(payload['schema_version']) | ||
| self.assertIsNone(payload['institution']) | ||
| self.assertIsNone(payload['institution_guid']) | ||
| self.assertIsNone(payload['discipline']) | ||
| self.assertIsNone(payload['collection']) | ||
| self.assertIsNone(payload['collection_guid']) | ||
| self.assertIsNone(payload['isa_number']) | ||
| self.assertIsNone(payload['discipline_type']) | ||
| self.assertIsNone(payload['geography_is_global']) | ||
| self.assertIn('version', payload) | ||
| self.assertIn('specify6_version', payload) | ||
|
|
||
| def test_system_info_after_guided_setup_returns_full_payload(self): | ||
| Spversion.objects.create(appversion='7', schemaversion='2.10') | ||
|
|
||
| c = Client() | ||
| c.force_login(self.specifyuser) | ||
| c.cookies['collection'] = str(self.collection.id) | ||
|
|
||
| with patch('specifyweb.backend.context.views.is_guided_setup_complete', return_value=True): | ||
| response = c.get('/context/system_info.json') | ||
|
|
||
| self._assertStatusCodeEqual(response, 200) | ||
| payload = json.loads(response.content.decode()) | ||
|
|
||
| self.assertTrue(payload['setup_complete']) | ||
| self.assertEqual(payload['database_version'], '7') | ||
| self.assertEqual(payload['schema_version'], '2.10') | ||
| self.assertEqual(payload['institution'], self.institution.name) | ||
| self.assertEqual(payload['institution_guid'], self.institution.guid) | ||
| self.assertEqual(payload['discipline'], self.discipline.name) | ||
| self.assertEqual(payload['collection'], self.collection.collectionname) | ||
| self.assertEqual(payload['collection_guid'], self.collection.guid) | ||
| self.assertEqual(payload['isa_number'], self.collection.isanumber) | ||
| self.assertEqual(payload['discipline_type'], self.discipline.type) | ||
| self.assertEqual( | ||
| payload['geography_is_global'], self.institution.issinglegeographytree | ||
| ) |
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
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
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
6 changes: 5 additions & 1 deletion
6
specifyweb/frontend/js_src/lib/tests/ajax/static/context/system_info.json
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,14 +1,18 @@ | ||
| { | ||
| "version": "(debug)", | ||
| "specify6_version": "6.8.03", | ||
| "setup_complete": true, | ||
| "database_version": "6.8.03", | ||
| "schema_version": "2.9", | ||
| "stats_url": "https://sp7-stats.specifycloud.org/capture", | ||
| "stats_2_url": "https://stats-2.specifycloud.org", | ||
| "database": "specify", | ||
| "institution": "University of Kansas Biodiversity Institute", | ||
| "institution_guid": "77ff1bff-af23-4647-b5d1-9d3c414fd003", | ||
| "discipline": "Ichthyology", | ||
| "collection": "KU Fish Voucher Collection", | ||
| "collection_guid": "3f55b3fa-292d-4170-bd46-66dca41d7f05", | ||
| "isa_number": "2014427" | ||
| "isa_number": "2014427", | ||
| "discipline_type": "fish", | ||
| "geography_is_global": true | ||
| } |
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.