-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add method to detect rows are written to the MockBackend
#292
Conversation
✅ 35/35 passed, 7 flaky, 4 skipped, 9m4s total Flaky tests:
Running from acceptance #412 |
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.
I think there's a missing test for:
- Write to a table (mode irrelevant)
- Write to a table: mode=overwrite, rows=[]
- Check that has-rows is true.
@@ -372,6 +372,18 @@ def rows_written_for(self, full_name: str, mode: str) -> list[DataclassInstance] | |||
rows += stub_rows | |||
return rows | |||
|
|||
def has_rows_written_for(self, full_name: str) -> bool: |
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.
Although I think I came up with this name, I'm not sure if there's something better? What troubles me is that the name is misleading for when []
was written: the plain-language description of this situation is that the table has been written but doesn't contain any rows for the table, but this doesn't really match the function name.
Any ideas?
* Added method to detect rows are written to the `MockBackend` ([#292](#292)). In this commit, the `MockBackend` class in the 'backends.py' file has been updated with a new method, 'has_rows_written_for', which allows for differentiation between a table that has never been written to and one with zero rows. This method checks if a specific table has been written to by iterating over the table stubs in the `_save_table` attribute and returning `True` if the given full name matches any of the stub full names. Additionally, the class has been supplemented with the `rows_written_for` method, which takes a table name and mode as input and returns a list of rows written to that table in the given mode. Furthermore, several new test cases have been added to test the functionality of the `MockBackend` class, including checking if the `has_rows_written_for` method correctly identifies when there are no rows written, when there are zero rows written, and when rows are written after the first and second write operations. These changes improve the overall testing coverage of the project and aid in testing the functionality of the `MockBackend` class. The new methods are accompanied by documentation strings that explain their purpose and functionality.
* Added method to detect rows are written to the `MockBackend` ([#292](#292)). In this commit, the `MockBackend` class in the 'backends.py' file has been updated with a new method, 'has_rows_written_for', which allows for differentiation between a table that has never been written to and one with zero rows. This method checks if a specific table has been written to by iterating over the table stubs in the `_save_table` attribute and returning `True` if the given full name matches any of the stub full names. Additionally, the class has been supplemented with the `rows_written_for` method, which takes a table name and mode as input and returns a list of rows written to that table in the given mode. Furthermore, several new test cases have been added to test the functionality of the `MockBackend` class, including checking if the `has_rows_written_for` method correctly identifies when there are no rows written, when there are zero rows written, and when rows are written after the first and second write operations. These changes improve the overall testing coverage of the project and aid in testing the functionality of the `MockBackend` class. The new methods are accompanied by documentation strings that explain their purpose and functionality.
See this comment on motivation