-
Notifications
You must be signed in to change notification settings - Fork 32
Modernize project #739
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
Modernize project #739
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
876ecc8
Update pyproject.toml
surister 3651e56
Add deps and metadata
surister 45d8140
Add proper error formating to `BlobException`
surister 15d53ec
Migrate test_cursor to pytest format.
surister c8dfa3a
Migrate several http tests
surister d854bbf
Rename `REQUEST` to `REQUEST_PATH` and move it to conftest.py with `f…
surister 6c0c8b6
Migrate more tests
surister aa7794f
fix typo
surister 8f46388
Clean imports
surister 3bc6cff
Add specific tests for serialization
surister 8cc192d
Add `temp_env` util function to temporarily set env variables with a …
surister 4a2fbf8
Migrate client ca tests
surister b8a79fc
Migrate more tests
surister bf2903a
Migrate test_connection
surister 6db454d
refactor fail_sometimes
surister 010fcfa
Remove temp_env util function
surister 08e9401
Migrate test_http and fix some test_cursor
surister 1548b03
Fix linting
surister 1cc2986
Fix CI
surister 39ad8c9
Fix CI
surister 0516259
Fix tests
surister 65255bc
Renew default __repr__ implementation
surister 10bfaec
Add more tests
surister 7427104
Add more tests for cursors
surister 7a914be
Add test super_len
surister 62d57d5
Add more tests
surister dea1e6e
Update pyproject.toml
surister 82831cf
Add deps and metadata
surister 13cba1d
Add proper error formating to `BlobException`
surister e516df5
Migrate test_cursor to pytest format.
surister 6fdf2f3
Migrate several http tests
surister 05828dd
Rename `REQUEST` to `REQUEST_PATH` and move it to conftest.py with `f…
surister 84cc663
Migrate more tests
surister 3586e37
fix typo
surister 5c89231
Clean imports
surister fcaae2b
Add specific tests for serialization
surister e23e95c
Add `temp_env` util function to temporarily set env variables with a …
surister cf69bc8
Migrate client ca tests
surister 4f0912e
Migrate more tests
surister 49b4a83
Migrate test_connection
surister 9b50cd2
refactor fail_sometimes
surister 596fdbc
Remove temp_env util function
surister 82dfa7c
Migrate test_http and fix some test_cursor
surister 8bd3de3
Fix linting
surister 41a2bcc
Fix CI
surister fd2aaaa
Fix CI
surister 5dba2b6
Fix tests
surister a96903e
Renew default __repr__ implementation
surister 2556826
Add more tests
surister 8562976
Add more tests for cursors
surister c704280
Add test super_len
surister c4da897
Add more tests
surister abdf3db
Merge remote-tracking branch 'origin/feat/modernize-project' into fea…
surister c4371fc
Add test for update pool kwags
surister 980bbc5
Add test for cursor description
surister 5096b3e
Add test for cursor rowcount
surister a4a6b37
fix format
surister c4832b5
Add tests for blobs
surister 833f36d
add changelog entry
surister 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| from io import BytesIO | ||
| from unittest.mock import MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from crate.client.blob import BlobContainer | ||
|
|
||
|
|
||
| def test_container(): | ||
| """Verify a container can be instantiated.""" | ||
| expected_name = "somename" | ||
| container = BlobContainer(expected_name, MagicMock()) | ||
| assert container.container_name == expected_name | ||
|
|
||
|
|
||
| def test_container_digest(): | ||
| digester = BlobContainer("", MagicMock())._compute_digest | ||
|
|
||
| # sha1 of some_data. | ||
| some_data, expected_digest = ( | ||
| b"some_data_123456", | ||
| "51bea75c0f26998083ef3717a489f2dc05818e8d", | ||
| ) | ||
| result = digester(BytesIO(some_data)) | ||
| assert result == expected_digest | ||
|
|
||
| with pytest.raises(AttributeError): | ||
| digester("someundigestabledata") | ||
|
|
||
|
|
||
| def test_container_put(): | ||
| """Test the logic of container put method""" | ||
| some_data, expected_digest = ( | ||
| b"some_data_123456", | ||
| "51bea75c0f26998083ef3717a489f2dc05818e8d", | ||
| ) | ||
| expected_container_name = "somename" | ||
| m = MagicMock() | ||
| m.client.blob_put = MagicMock() | ||
| container = BlobContainer(expected_container_name, m) | ||
|
|
||
| result = container.put(BytesIO(some_data)) | ||
| assert result == expected_digest | ||
|
|
||
| new_digest = "asdfn" | ||
| data = BytesIO(some_data) | ||
| result = container.put(data, digest=new_digest) | ||
| assert isinstance(result, MagicMock) | ||
| assert m.client.blob_put.call_count == 2 | ||
| assert m.client.blob_put.call_args.args == ( | ||
| expected_container_name, | ||
| new_digest, | ||
| data, | ||
| ) |
Oops, something went wrong.
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.
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 the code is still compatible down to Python 3.6?
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.
We have two users running 2.7, so perhaps even lower than 3.6