Skip to content

Commit d9c6112

Browse files
authored
fix(logging): fixed test to actually test (#13886)
* Remove deprecated samples Removal of appengine/flexible_python37_and_earlier path for deprecation. As per my search on Code Search, there are no samples using these deprecated code snippets anymore. b/475332253 * fix(logging): fixed test to actually test * - Removed unnecessary comment. - Updated requirements. - Changed fixture in snippets test. * Fixing linting issues.
1 parent 7d099b4 commit d9c6112

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

logging/samples/snippets/export_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# limitations under the License.
1414

1515
import os
16-
import re
1716
import random
17+
import re
1818
import string
1919
import time
2020

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
google-cloud-logging==3.10.0
2-
google-cloud-bigquery==3.25.0
3-
google-cloud-storage==2.17.0
4-
google-cloud-pubsub==2.22.0
1+
google-cloud-logging==3.13.0
2+
google-cloud-bigquery==3.40.1
3+
google-cloud-storage==3.7.0
4+
google-cloud-pubsub==2.35.0

logging/samples/snippets/snippets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def delete_logger(logger_name):
9090

9191

9292
if __name__ == "__main__":
93+
9394
parser = argparse.ArgumentParser(
9495
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
9596
)

logging/samples/snippets/snippets_test.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
TEST_LOGGER_NAME = "example_log_{}".format(uuid.uuid4().hex)
26+
TEST_TEXT = "Hello, world."
2627

2728

2829
@pytest.fixture
@@ -44,13 +45,24 @@ def eventually_consistent_test():
4445
eventually_consistent_test()
4546

4647

47-
def test_write():
48+
def test_write(capsys):
49+
4850
snippets.write_entry(TEST_LOGGER_NAME)
4951

52+
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
53+
def eventually_consistent_test():
54+
snippets.list_entries(TEST_LOGGER_NAME)
55+
out, _ = capsys.readouterr()
56+
assert TEST_TEXT in out
57+
58+
eventually_consistent_test()
59+
5060

5161
def test_delete(example_log, capsys):
5262
@backoff.on_exception(backoff.expo, NotFound, max_time=120)
5363
def eventually_consistent_test():
5464
snippets.delete_logger(TEST_LOGGER_NAME)
5565
out, _ = capsys.readouterr()
5666
assert TEST_LOGGER_NAME in out
67+
68+
eventually_consistent_test()

logging/samples/snippets/usage_guide.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ def main():
557557
except Exception as error: # pylint: disable=broad-except
558558
print(" ERROR: %r" % (error,))
559559
for item in to_delete:
560+
pass
560561
_backoff_not_found(item.delete)
561562

562563

0 commit comments

Comments
 (0)