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

added content assertion for assert_file_uploaded and assert_file_dbfs_uploaded in MockInstallation #101

Merged
merged 3 commits into from
May 7, 2024

Conversation

nkvuong
Copy link
Contributor

@nkvuong nkvuong commented May 7, 2024

Add expected: bytes parameter to assert that the content uploaded to MockInstallation is correct

@nkvuong nkvuong requested a review from nfx as a code owner May 7, 2024 11:08
@nkvuong nkvuong changed the title add content assertion for assert_file_uploaded and assert_file_dbfs_uploaded added content assertion for assert_file_uploaded and assert_file_dbfs_uploaded in MockInstallation May 7, 2024
Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 78.49%. Comparing base (a5a8563) to head (2144b17).

Files Patch % Lines
src/databricks/labs/blueprint/installation.py 58.33% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
- Coverage   78.56%   78.49%   -0.07%     
==========================================
  Files          14       14              
  Lines        1474     1479       +5     
  Branches      261      263       +2     
==========================================
+ Hits         1158     1161       +3     
- Misses        229      230       +1     
- Partials       87       88       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

nfx pushed a commit to databrickslabs/ucx that referenced this pull request May 7, 2024
…allation)` (#1649)

## Changes
- Replaced all usage of `create_autospec(Installation)` with
`MockInstallation`
- One final usage requires
databrickslabs/blueprint#101

### Tests
<!-- How is this tested? Please see the checklist below and also
describe any other relevant tests -->

- [x] manually tested
- [x] verified on staging environment (screenshot attached)
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@nfx nfx merged commit aa3bf8c into databrickslabs:main May 7, 2024
10 of 13 checks passed
aminmovahed-db pushed a commit to aminmovahed-db/blueprint that referenced this pull request May 8, 2024
…bfs_uploaded` in `MockInstallation` (databrickslabs#101)

Add `expected: bytes` parameter to assert that the content uploaded to
MockInstallation is correct
nfx added a commit that referenced this pull request May 8, 2024
* Added content assertion for `assert_file_uploaded` and `assert_file_dbfs_uploaded` in `MockInstallation` ([#101](#101)). The recent commit introduces a content assertion feature to the `MockInstallation` class, enhancing its testing capabilities. This is achieved by adding an optional `expected` parameter of type `bytes` to the `assert_file_uploaded` and `assert_file_dbfs_uploaded` methods, allowing users to verify the uploaded content's correctness. The `_assert_upload` method has also been updated to accept this new parameter, ensuring the actual uploaded content matches the expected content. Furthermore, the commit includes informative docstrings for the new and updated methods, providing clear explanations of their functionality and usage. To support these improvements, new test cases `test_assert_file_uploaded` and `test_load_empty_data_class` have been added to the `tests/unit/test_installation.py` file, enabling more rigorous testing of the `MockInstallation` class and ensuring that the expected content is uploaded correctly.
* Added handling for partial functions in `parallel.Threads` ([#93](#93)). In this release, we have enhanced the `parallel.Threads` module with the ability to handle partial functions, addressing issue [#93](#93). This improvement includes the addition of a new static method, `_get_result_function_signature`, to obtain the signature of a function or a string representation of its arguments and keywords if it is a partial function. The `_wrap_result` class method has also been updated to log an error message with the function's signature if an exception occurs. Furthermore, we have added a new test case, `test_odd_partial_failed`, to the unit tests, ensuring that the `gather` function handles partial functions that raise errors correctly. The Python version required for this project remains at 3.10, and the `pyproject.toml` file has been updated to include "isort", "mypy", "types-PyYAML", and `types-requests` in the list of dependencies. These adjustments are aimed at improving the functionality and type checking in the `parallel.Threads` module.
* Align configurations with UCX project ([#96](#96)). This commit brings project configurations in line with the UCX project through various fixes and updates, enhancing compatibility and streamlining collaboration. It addresses pylint configuration warnings, adjusts GitHub Actions workflows, and refines the `pyproject.toml` file. Additionally, the `NiceFormatter` class in `logger.py` has been improved for better code readability, and the versioning scheme has been updated to ensure SemVer and PEP440 compliance, making it easier to manage and understand the project's versioning. Developers adopting the project will benefit from these alignments, as they promote adherence to the project's standards and up-to-date best practices.
* Check backwards compatibility with UCX, Remorph, and LSQL ([#84](#84)). This release includes an update to the dependabot configuration to check for daily updates in both the pip and github-actions package ecosystems, with a new directory parameter added for the pip ecosystem for more precise update management. Additionally, a new GitHub Actions workflow, "downstreams", has been added to ensure backwards compatibility with UCX, Remorph, and LSQL by running automated downstream checks on pull requests, merge groups, and pushes to the main branch. The workflow has appropriate permissions for writing id-tokens, reading contents, and writing pull-requests, and runs the downstreams action from the databrickslabs/sandbox repository using GITHUB_TOKEN for authentication. These changes improve the security and maintainability of the project by ensuring compatibility with downstream projects and staying up-to-date with the latest package versions, reducing the risk of potential security vulnerabilities and bugs.

Dependency updates:

 * Bump actions/setup-python from 4 to 5 ([#89](#89)).
 * Bump softprops/action-gh-release from 1 to 2 ([#87](#87)).
 * Bump actions/checkout from 2.5.0 to 4.1.2 ([#88](#88)).
 * Bump codecov/codecov-action from 1 to 4 ([#85](#85)).
 * Bump actions/checkout from 4.1.2 to 4.1.3 ([#95](#95)).
 * Bump actions/checkout from 4.1.3 to 4.1.5 ([#100](#100)).
@nfx nfx mentioned this pull request May 8, 2024
nfx added a commit that referenced this pull request May 8, 2024
* Added content assertion for `assert_file_uploaded` and
`assert_file_dbfs_uploaded` in `MockInstallation`
([#101](#101)). The
recent commit introduces a content assertion feature to the
`MockInstallation` class, enhancing its testing capabilities. This is
achieved by adding an optional `expected` parameter of type `bytes` to
the `assert_file_uploaded` and `assert_file_dbfs_uploaded` methods,
allowing users to verify the uploaded content's correctness. The
`_assert_upload` method has also been updated to accept this new
parameter, ensuring the actual uploaded content matches the expected
content. Furthermore, the commit includes informative docstrings for the
new and updated methods, providing clear explanations of their
functionality and usage. To support these improvements, new test cases
`test_assert_file_uploaded` and `test_load_empty_data_class` have been
added to the `tests/unit/test_installation.py` file, enabling more
rigorous testing of the `MockInstallation` class and ensuring that the
expected content is uploaded correctly.
* Added handling for partial functions in `parallel.Threads`
([#93](#93)). In this
release, we have enhanced the `parallel.Threads` module with the ability
to handle partial functions, addressing issue
[#93](#93). This
improvement includes the addition of a new static method,
`_get_result_function_signature`, to obtain the signature of a function
or a string representation of its arguments and keywords if it is a
partial function. The `_wrap_result` class method has also been updated
to log an error message with the function's signature if an exception
occurs. Furthermore, we have added a new test case,
`test_odd_partial_failed`, to the unit tests, ensuring that the `gather`
function handles partial functions that raise errors correctly. The
Python version required for this project remains at 3.10, and the
`pyproject.toml` file has been updated to include "isort", "mypy",
"types-PyYAML", and `types-requests` in the list of dependencies. These
adjustments are aimed at improving the functionality and type checking
in the `parallel.Threads` module.
* Align configurations with UCX project
([#96](#96)). This
commit brings project configurations in line with the UCX project
through various fixes and updates, enhancing compatibility and
streamlining collaboration. It addresses pylint configuration warnings,
adjusts GitHub Actions workflows, and refines the `pyproject.toml` file.
Additionally, the `NiceFormatter` class in `logger.py` has been improved
for better code readability, and the versioning scheme has been updated
to ensure SemVer and PEP440 compliance, making it easier to manage and
understand the project's versioning. Developers adopting the project
will benefit from these alignments, as they promote adherence to the
project's standards and up-to-date best practices.
* Check backwards compatibility with UCX, Remorph, and LSQL
([#84](#84)). This
release includes an update to the dependabot configuration to check for
daily updates in both the pip and github-actions package ecosystems,
with a new directory parameter added for the pip ecosystem for more
precise update management. Additionally, a new GitHub Actions workflow,
"downstreams", has been added to ensure backwards compatibility with
UCX, Remorph, and LSQL by running automated downstream checks on pull
requests, merge groups, and pushes to the main branch. The workflow has
appropriate permissions for writing id-tokens, reading contents, and
writing pull-requests, and runs the downstreams action from the
databrickslabs/sandbox repository using GITHUB_TOKEN for authentication.
These changes improve the security and maintainability of the project by
ensuring compatibility with downstream projects and staying up-to-date
with the latest package versions, reducing the risk of potential
security vulnerabilities and bugs.

Dependency updates:

* Bump actions/setup-python from 4 to 5
([#89](#89)).
* Bump softprops/action-gh-release from 1 to 2
([#87](#87)).
* Bump actions/checkout from 2.5.0 to 4.1.2
([#88](#88)).
* Bump codecov/codecov-action from 1 to 4
([#85](#85)).
* Bump actions/checkout from 4.1.2 to 4.1.3
([#95](#95)).
* Bump actions/checkout from 4.1.3 to 4.1.5
([#100](#100)).
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.

2 participants