Skip to content
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

Merged
merged 14 commits into from
Sep 19, 2024

Conversation

JCZuurmond
Copy link
Member

See this comment on motivation

Copy link

github-actions bot commented Sep 19, 2024

✅ 35/35 passed, 7 flaky, 4 skipped, 9m4s total

Flaky tests:

  • 🤪 test_dashboard_deploys_dashboard_with_display_name (7.403s)
  • 🤪 test_dashboards_creates_exported_dashboard_definition (7.968s)
  • 🤪 test_dashboard_deploys_dashboard_the_same_as_created_dashboard (8.663s)
  • 🤪 test_dashboard_deploys_dashboard_with_big_widget (7.475s)
  • 🤪 test_dashboard_deploys_dashboard_with_counter_variation (7.872s)
  • 🤪 test_dashboards_creates_dashboard_with_markdown_header (7.784s)
  • 🤪 test_dashboards_creates_dashboard_from_query_with_cte (9.631s)

Running from acceptance #412

@JCZuurmond JCZuurmond marked this pull request as draft September 19, 2024 09:43
@JCZuurmond JCZuurmond marked this pull request as ready for review September 19, 2024 09:55
@JCZuurmond JCZuurmond requested a review from asnare September 19, 2024 09:56
Copy link
Contributor

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:
Copy link
Contributor

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?

@nfx nfx merged commit 8cf5dc4 into main Sep 19, 2024
8 checks passed
@nfx nfx deleted the feat/add-has-rows-written-for-to-mock-backend branch September 19, 2024 13:48
nfx added a commit that referenced this pull request Sep 19, 2024
* 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.
@nfx nfx mentioned this pull request Sep 19, 2024
nfx added a commit that referenced this pull request Sep 19, 2024
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants