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

style: replace potentially disrespectful terms and language #378

Merged
merged 2 commits into from
Feb 10, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2683,13 +2683,13 @@ def create_resumable_upload_session(
extra_headers["Origin"] = origin

try:
dummy_stream = BytesIO(b"")
fake_stream = BytesIO(b"")
# Send a fake the chunk size which we **know** will be acceptable
# to the `ResumableUpload` constructor. The chunk size only
# matters when **sending** bytes to an upload.
upload, _ = self._initiate_resumable_upload(
client,
dummy_stream,
fake_stream,
content_type,
size,
None,
Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def system(session):
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
# Sanity check: Only run tests if the environment variable is set.
# Environment check: Only run tests if the environment variable is set.
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
session.skip("Credentials must be set via environment variable")

system_test_exists = os.path.exists(system_test_path)
system_test_folder_exists = os.path.exists(system_test_folder_path)
# Sanity check: only run tests if found.
# Environment check: only run tests if found.
if not system_test_exists and not system_test_folder_exists:
session.skip("System tests were not found")

Expand Down
62 changes: 31 additions & 31 deletions tests/unit/test__signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class CET(_UTC):
self.assertEqual(self._call_fut(expiration_other), cet_seconds)

def test_w_expiration_timedelta_seconds(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
utc_seconds = _utc_seconds(dummy_utcnow)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
utc_seconds = _utc_seconds(fake_utcnow)
expiration_as_delta = datetime.timedelta(seconds=10)

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_as_delta)
Expand All @@ -108,12 +108,12 @@ def test_w_expiration_timedelta_seconds(self):
utcnow.assert_called_once_with()

def test_w_expiration_timedelta_days(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
utc_seconds = _utc_seconds(dummy_utcnow)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
utc_seconds = _utc_seconds(fake_utcnow)
expiration_as_delta = datetime.timedelta(days=1)

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_as_delta)
Expand All @@ -138,13 +138,13 @@ def test_w_expiration_none(self):
self._call_fut(None)

def test_w_expiration_int_gt_seven_days(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
delta = datetime.timedelta(days=10)
expiration_utc = dummy_utcnow + delta
expiration_utc = fake_utcnow + delta
expiration_seconds = _utc_seconds(expiration_utc)

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)

with patch as utcnow:
Expand All @@ -153,11 +153,11 @@ def test_w_expiration_int_gt_seven_days(self):
utcnow.assert_called_once_with()

def test_w_expiration_int(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
expiration_seconds = 10

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)

with patch as utcnow:
Expand All @@ -167,12 +167,12 @@ def test_w_expiration_int(self):
utcnow.assert_called_once_with()

def test_w_expiration_naive_datetime(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
delta = datetime.timedelta(seconds=10)
expiration_no_tz = dummy_utcnow + delta
expiration_no_tz = fake_utcnow + delta

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_no_tz)
Expand All @@ -183,12 +183,12 @@ def test_w_expiration_naive_datetime(self):
def test_w_expiration_utc_datetime(self):
from google.cloud._helpers import UTC

dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, UTC)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, UTC)
delta = datetime.timedelta(seconds=10)
expiration_utc = dummy_utcnow + delta
expiration_utc = fake_utcnow + delta

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_utc)
Expand All @@ -205,13 +205,13 @@ class CET(_UTC):
_utcoffset = datetime.timedelta(hours=1)

zone = CET()
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, UTC)
dummy_cetnow = dummy_utcnow.astimezone(zone)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0, UTC)
fake_cetnow = fake_utcnow.astimezone(zone)
delta = datetime.timedelta(seconds=10)
expiration_other = dummy_cetnow + delta
expiration_other = fake_cetnow + delta

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_other)
Expand All @@ -220,11 +220,11 @@ class CET(_UTC):
utcnow.assert_called_once_with()

def test_w_expiration_timedelta(self):
dummy_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
fake_utcnow = datetime.datetime(2004, 8, 19, 0, 0, 0, 0)
expiration_as_delta = datetime.timedelta(seconds=10)

patch = mock.patch(
"google.cloud.storage._signing.NOW", return_value=dummy_utcnow
"google.cloud.storage._signing.NOW", return_value=fake_utcnow
)
with patch as utcnow:
result = self._call_fut(expiration_as_delta)
Expand All @@ -246,7 +246,7 @@ def test_it(self):
credentials = _make_credentials(signer_email=account_name)
credentials.sign_bytes.return_value = sig_bytes
expiration = 100
string_to_sign = "dummy_signature"
string_to_sign = "fake_signature"
result = self._call_fut(credentials, expiration, string_to_sign)

expected = {
Expand Down Expand Up @@ -770,20 +770,20 @@ def test_get_v4_now_dtstamps(self):
self.assertEqual(datestamp, "20200312")


_DUMMY_SERVICE_ACCOUNT = None
_FAKE_SERVICE_ACCOUNT = None


def dummy_service_account():
global _DUMMY_SERVICE_ACCOUNT
def fake_service_account():
global _FAKE_SERVICE_ACCOUNT

from google.oauth2.service_account import Credentials

if _DUMMY_SERVICE_ACCOUNT is None:
_DUMMY_SERVICE_ACCOUNT = Credentials.from_service_account_info(
if _FAKE_SERVICE_ACCOUNT is None:
_FAKE_SERVICE_ACCOUNT = Credentials.from_service_account_info(
_SERVICE_ACCOUNT_JSON
)

return _DUMMY_SERVICE_ACCOUNT
return _FAKE_SERVICE_ACCOUNT


_API_ACCESS_ENDPOINT = "https://storage.googleapis.com"
Expand All @@ -792,7 +792,7 @@ def dummy_service_account():
def _run_conformance_test(
resource, test_data, api_access_endpoint=_API_ACCESS_ENDPOINT
):
credentials = dummy_service_account()
credentials = fake_service_account()
url = Test_generate_signed_url_v4._call_fut(
credentials,
resource,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2992,11 +2992,11 @@ def test_page_non_empty_response(self):
name = "name"
bucket = self._make_one(client=client, name=name)

def dummy_response():
def fake_response():
return response

iterator = bucket.list_blobs()
iterator._get_next_page_response = dummy_response
iterator._get_next_page_response = fake_response

page = six.next(iterator.pages)
self.assertEqual(page.prefixes, ("foo",))
Expand All @@ -3023,11 +3023,11 @@ def test_cumulative_prefixes(self):
bucket = self._make_one(client=client, name=name)
responses = [response1, response2]

def dummy_response():
def fake_response():
return responses.pop(0)

iterator = bucket.list_blobs()
iterator._get_next_page_response = dummy_response
iterator._get_next_page_response = fake_response

# Parse first response.
pages_iter = iterator.pages
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"postPolicyV4Tests"
]
_POST_POLICY_TESTS = [test for test in _CONFORMANCE_TESTS if "policyInput" in test]
_DUMMY_CREDENTIALS = Credentials.from_service_account_info(_SERVICE_ACCOUNT_JSON)
_FAKE_CREDENTIALS = Credentials.from_service_account_info(_SERVICE_ACCOUNT_JSON)


def _make_credentials():
Expand Down Expand Up @@ -1446,11 +1446,11 @@ def test_list_buckets_page_non_empty_response(self):
blob_name = "bucket-name"
response = {"items": [{"name": blob_name}]}

def dummy_response():
def fake_response():
return response

iterator = client.list_buckets()
iterator._get_next_page_response = dummy_response
iterator._get_next_page_response = fake_response

page = six.next(iterator.pages)
self.assertEqual(page.num_items, 1)
Expand Down Expand Up @@ -2033,7 +2033,7 @@ def test_conformance_post_policy(test_data):
in_data = test_data["policyInput"]
timestamp = datetime.datetime.strptime(in_data["timestamp"], "%Y-%m-%dT%H:%M:%SZ")

client = Client(credentials=_DUMMY_CREDENTIALS, project="PROJECT")
client = Client(credentials=_FAKE_CREDENTIALS, project="PROJECT")

# mocking time functions
with mock.patch("google.cloud.storage._signing.NOW", return_value=timestamp):
Expand All @@ -2048,7 +2048,7 @@ def test_conformance_post_policy(test_data):
blob_name=in_data["object"],
conditions=_prepare_conditions(in_data),
fields=in_data.get("fields"),
credentials=_DUMMY_CREDENTIALS,
credentials=_FAKE_CREDENTIALS,
expiration=in_data["expiration"],
virtual_hosted_style=in_data.get("urlStyle")
== "VIRTUAL_HOSTED_STYLE",
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/url_signer_v4_test_account.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "service_account",
"project_id": "dummy-project-id",
"project_id": "test-project-id",
"private_key_id": "ffffffffffffffffffffffffffffffffffffffff",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCsPzMirIottfQ2\nryjQmPWocSEeGo7f7Q4/tMQXHlXFzo93AGgU2t+clEj9L5loNhLVq+vk+qmnyDz5\nQ04y8jVWyMYzzGNNrGRW/yaYqnqlKZCy1O3bmnNjV7EDbC/jE1ZLBY0U3HaSHfn6\nS9ND8MXdgD0/ulRTWwq6vU8/w6i5tYsU7n2LLlQTl1fQ7/emO9nYcCFJezHZVa0H\nmeWsdHwWsok0skwQYQNIzP3JF9BpR5gJT2gNge6KopDesJeLoLzaX7cUnDn+CAnn\nLuLDwwSsIVKyVxhBFsFXPplgpaQRwmGzwEbf/Xpt9qo26w2UMgn30jsOaKlSeAX8\ncS6ViF+tAgMBAAECggEACKRuJCP8leEOhQziUx8Nmls8wmYqO4WJJLyk5xUMUC22\nSI4CauN1e0V8aQmxnIc0CDkFT7qc9xBmsMoF+yvobbeKrFApvlyzNyM7tEa/exh8\nDGD/IzjbZ8VfWhDcUTwn5QE9DCoon9m1sG+MBNlokB3OVOt8LieAAREdEBG43kJu\nyQTOkY9BGR2AY1FnAl2VZ/jhNDyrme3tp1sW1BJrawzR7Ujo8DzlVcS2geKA9at7\n55ua5GbHz3hfzFgjVXDfnkWzId6aHypUyqHrSn1SqGEbyXTaleKTc6Pgv0PgkJjG\nhZazWWdSuf1T5Xbs0OhAK9qraoAzT6cXXvMEvvPt6QKBgQDXcZKqJAOnGEU4b9+v\nOdoh+nssdrIOBNMu1m8mYbUVYS1aakc1iDGIIWNM3qAwbG+yNEIi2xi80a2RMw2T\n9RyCNB7yqCXXVKLBiwg9FbKMai6Vpk2bWIrzahM9on7AhCax/X2AeOp+UyYhFEy6\nUFG4aHb8THscL7b515ukSuKb5QKBgQDMq+9PuaB0eHsrmL6q4vHNi3MLgijGg/zu\nAXaPygSYAwYW8KglcuLZPvWrL6OG0+CrfmaWTLsyIZO4Uhdj7MLvX6yK7IMnagvk\nL3xjgxSklEHJAwi5wFeJ8ai/1MIuCn8p2re3CbwISKpvf7Sgs/W4196P4vKvTiAz\njcTiSYFIKQKBgCjMpkS4O0TakMlGTmsFnqyOneLmu4NyIHgfPb9cA4n/9DHKLKAT\noaWxBPgatOVWs7RgtyGYsk+XubHkpC6f3X0+15mGhFwJ+CSE6tN+l2iF9zp52vqP\nQwkjzm7+pdhZbmaIpcq9m1K+9lqPWJRz/3XXuqi+5xWIZ7NaxGvRjqaNAoGAdK2b\nutZ2y48XoI3uPFsuP+A8kJX+CtWZrlE1NtmS7tnicdd19AtfmTuUL6fz0FwfW4Su\nlQZfPT/5B339CaEiq/Xd1kDor+J7rvUHM2+5p+1A54gMRGCLRv92FQ4EON0RC1o9\nm2I4SHysdO3XmjmdXmfp4BsgAKJIJzutvtbqlakCgYB+Cb10z37NJJ+WgjDt+yT2\nyUNH17EAYgWXryfRgTyi2POHuJitd64Xzuy6oBVs3wVveYFM6PIKXlj8/DahYX5I\nR2WIzoCNLL3bEZ+nC6Jofpb4kspoAeRporj29SgesK6QBYWHWX2H645RkRGYGpDo\n51gjy9m/hSNqBbH2zmh04A==\n-----END PRIVATE KEY-----\n",
"client_email": "test-iam-credentials@dummy-project-id.iam.gserviceaccount.com",
"client_email": "test-iam-credentials@test-project-id.iam.gserviceaccount.com",
"client_id": "000000000000000000000",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-iam-credentials%40dummy-project-id.iam.gserviceaccount.com"
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-iam-credentials%40test-project-id.iam.gserviceaccount.com"
}