From 3801122fe352d753d7a231472e89bc2c03064141 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 24 Nov 2020 17:22:32 -0500 Subject: [PATCH] tests: coverage --- tests/unit/test_blob.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_blob.py b/tests/unit/test_blob.py index 770af50d5..dd7f13a78 100644 --- a/tests/unit/test_blob.py +++ b/tests/unit/test_blob.py @@ -1642,8 +1642,6 @@ def _download_as_text_helper( if payload is None: if encoding is not None: payload = expected_value.encode(encoding) - elif charset is not None: - payload = expected_value.encode(charset) else: payload = expected_value.encode() @@ -1696,8 +1694,8 @@ def _download_as_text_helper( blob.download_as_bytes.assert_called_once_with( client=client, - start=client, - end=client, + start=start, + end=end, raw_download=raw_download, timeout=expected_timeout, if_generation_match=if_generation_match, @@ -1712,6 +1710,15 @@ def test_download_as_text_wo_raw(self): def test_download_as_text_w_raw(self): self._download_as_text_helper(raw_download=True) + def test_download_as_text_w_client(self): + self._download_as_text_helper(raw_download=False, client=object()) + + def test_download_as_text_w_start(self): + self._download_as_text_helper(raw_download=False, start=123) + + def test_download_as_text_w_end(self): + self._download_as_text_helper(raw_download=False, end=456) + def test_download_as_text_w_custom_timeout(self): self._download_as_text_helper(raw_download=False, timeout=9.58) @@ -1727,6 +1734,17 @@ def test_download_as_text_w_if_metageneration_match(self): def test_download_as_text_w_if_metageneration_not_match(self): self._download_as_text_helper(raw_download=False, if_metageneration_not_match=6) + def test_download_as_text_w_encoding(self): + encoding = "utf-16" + self._download_as_text_helper( + raw_download=False, encoding=encoding, + ) + + def test_download_as_text_w_no_charset(self): + self._download_as_text_helper( + raw_download=False, no_charset=True, + ) + def test_download_as_text_w_non_ascii_w_explicit_encoding(self): expected_value = u"\x0AFe" encoding = "utf-16"