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

chore: updated testing constraints #34

Merged
merged 24 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
testing changes
  • Loading branch information
galz10 committed Jan 30, 2023
commit 404f3c614a07312a68489a4061a14a2e4613b91d
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
include_package_data=True,
install_requires=(
"google-api-core >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
"libcst >= 0.2.5",
"pandas >= 1.0.0, <1.5.0",
"proto-plus >= 1.22.0, <2.0.0dev",
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'",
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,39 @@ def test_document_from_gcs_with_multiple_shards(get_bytes_multiple_files_mock):
assert len(actual.pages) == 48


@mock.patch("google.cloud.documentai_toolbox.wrappers.document.storage")
def test_get_bytes(mock_storage):

client = mock_storage.Client.return_value

mock_bucket = mock.Mock()
mock_bucket.blob.return_value.download_as_string.return_value = "test".encode(
"utf-8"
)

client.Bucket.return_value = mock_bucket

blobs = [
storage.Blob(
name="gs://test-directory/documentai/output/123456789/1/test_shard1.json",
bucket=mock_bucket,
),
storage.Blob(
name="gs://test-directory/documentai/output/123456789/1/test_shard2.json",
bucket=mock_bucket,
),
]

client.list_blobs.return_value = blobs

actual = document._get_bytes(
"gs://test-directory/documentai/", "output/123456789/1"
)
mock_storage.Client.assert_called_once()

assert actual == [b"", b""]


@mock.patch("google.cloud.documentai_toolbox.wrappers.document.storage")
def test_print_gcs_document_tree_with_one_folder(mock_storage, capfd):

Expand Down