-
Notifications
You must be signed in to change notification settings - Fork 145
fixed db seed error #2014
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
fixed db seed error #2014
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -246,10 +246,15 @@ def run_in_transaction_side_effect(callback, *args, **kwargs): | |||||||||||||||||||||||||||
| mock_transaction.insert.assert_called_once() | ||||||||||||||||||||||||||||
| args, kwargs = mock_transaction.insert.call_args | ||||||||||||||||||||||||||||
| self.assertEqual(kwargs['table'], 'Node') | ||||||||||||||||||||||||||||
| self.assertEqual(kwargs['columns'], ["subject_id", "name", "value", "types", "last_update_timestamp"]) | ||||||||||||||||||||||||||||
| self.assertEqual(len(kwargs['values']), 5) | ||||||||||||||||||||||||||||
| expected_subjects = ["StatisticalVariable", "StatVarGroup", "StatVarObservation", "Topic", "c/g/Root"] | ||||||||||||||||||||||||||||
| actual_subjects = [val[0] for val in kwargs['values']] | ||||||||||||||||||||||||||||
| actual_names = [val[1] for val in kwargs['values']] | ||||||||||||||||||||||||||||
| actual_values = [val[2] for val in kwargs['values']] | ||||||||||||||||||||||||||||
| self.assertEqual(actual_subjects, expected_subjects) | ||||||||||||||||||||||||||||
| self.assertEqual(actual_names, expected_subjects) | ||||||||||||||||||||||||||||
| self.assertEqual(actual_values, expected_subjects) | ||||||||||||||||||||||||||||
|
Comment on lines
252
to
+257
Contributor
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. These assertions can be made more concise and robust by iterating through the values and checking the properties for each row within a loop. This makes the test easier to read and extend if more fields need to be checked against the
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @patch('google.cloud.spanner.Client') | ||||||||||||||||||||||||||||
| def test_seed_database_already_exists(self, mock_spanner_client): | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
The
candidatesdictionary contains a lot of repeated strings. To improve maintainability and reduce redundancy, you could generate this dictionary programmatically. This would make it easier to add or modify fields in the future.By defining the unique parts (like the
types) separately and then building the full dictionary with a comprehension, the code becomes cleaner and less error-prone for future modifications.