This repository was archived by the owner on Dec 31, 2023. It is now read-only.
Repository navigation
feat: adding samples for default values #64
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a36d7d6
feat: adding samples for default values
m-strzelczyk 1b9ef96
chore: Applying changes from review
m-strzelczyk 7e66749
feat: Adding tests to default values samples.
m-strzelczyk 0fa1d4d
chore: Applying changes after tech-writer review.
m-strzelczyk cacc823
Merge remote-tracking branch 'origin/samples-default-values' into sam…
m-strzelczyk ecd8c4a
Merge branch 'master' into samples-default-values
m-strzelczyk a977b36
fix: Make the tests run in different projects
m-strzelczyk d9d327d
chore: Review suggestions applied.
m-strzelczyk 985c40e
Merge remote-tracking branch 'origin/samples-default-values' into sam…
m-strzelczyk 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
feat: Adding tests to default values samples.
- Loading branch information
commit 7e6674985816387f20316a7c3d7ab96c254d0a1d
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| pytest==6.2.4 | ||
| pytest==6.2.4 | ||
| google-cloud-storage==1.39.0 |
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,65 @@ | ||
| # Copyright 2021 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import typing | ||
| import uuid | ||
|
|
||
| import google.auth | ||
| import google.cloud.storage as storage | ||
| import pytest | ||
|
|
||
| from sample_default_values import \ | ||
| disable_usage_export, get_usage_export_bucket, set_usage_export_bucket | ||
|
|
||
| PROJECT = google.auth.default()[1] | ||
| BUCKET_NAME = "test" + uuid.uuid4().hex[:10] | ||
| TEST_PREFIX = 'some-prefix' | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def temp_bucket(): | ||
| storage_client = storage.Client() | ||
| bucket = storage_client.create_bucket(BUCKET_NAME) | ||
| yield bucket | ||
| bucket.delete(force=True) | ||
|
|
||
|
|
||
| def test_set_usage_export_bucket_default(capsys: typing.Any, | ||
| temp_bucket: storage.Bucket) -> None: | ||
| set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name) | ||
| uel = get_usage_export_bucket(project_id=PROJECT) | ||
| assert(uel.bucket_name == temp_bucket.name) | ||
| assert(uel.report_name_prefix == 'usage_gce') | ||
| out, _ = capsys.readouterr() | ||
| assert('default prefix of `usage_gce`.' in out) | ||
|
|
||
| disable_usage_export(project_id=PROJECT) | ||
| uel = get_usage_export_bucket(project_id=PROJECT) | ||
| assert(uel.bucket_name == '') | ||
| assert(uel.report_name_prefix == '') | ||
|
|
||
|
|
||
| def test_set_usage_export_bucket_custom(capsys: typing.Any, | ||
| temp_bucket: storage.Bucket) -> None: | ||
| set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name, | ||
| report_name_prefix=TEST_PREFIX) | ||
| uel = get_usage_export_bucket(project_id=PROJECT) | ||
| assert(uel.bucket_name == temp_bucket.name) | ||
| assert(uel.report_name_prefix == TEST_PREFIX) | ||
| out, _ = capsys.readouterr() | ||
| assert('usage_gce' not in out) | ||
|
|
||
| disable_usage_export(project_id=PROJECT) | ||
| uel = get_usage_export_bucket(project_id=PROJECT) | ||
| assert(uel.bucket_name == '') | ||
| assert(uel.report_name_prefix == '') |
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.
Uh oh!
There was an error while loading. Please reload this page.