-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
68 lines (62 loc) · 2.15 KB
/
Copy pathtest.py
File metadata and controls
68 lines (62 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import main
def test_get_data():
try:
data=main.get_gtm_version_data(main.service)
print("\nTesting get_data")
assert data is not None
print("Testing get_data data is not None")
assert len(data) > 0
print("Testing get_data data len > 0")
print("Get data passed")
except Exception as e:
print(e)
def test_version():
try:
data=main.get_gtm_version_data(main.service)
print("\nTesting get_version")
assert data is not None
print("Testing get_data data is not None")
version = main.get_version(data)
assert len(version) > 0
print("Testing get_version version len > 0")
assert type(version) == str
print("Testing get_version version is string")
print("Get version passed")
except Exception as e:
print("Test version Failed")
print(e)
def test_cloud_storage_save():
print("\nTesting save_version_to_cloud")
try:
main.save_version_to_cloud(main.client, "test data", "test.json", "gtm-state-storage")
except Exception as e:
print("Test storage save failed...")
print(e)
try:
bucket = main.client.get_bucket("gtm-state-storage")
test = bucket.get_blob("test.json")
test_value = test.download_as_string()
assert test_value == b"test data", "test is {test_value}"
print(f"Test value is successfully written as {test_value}")
except Exception as e:
print("Tests storage save failed...")
print(e)
def test_cloud_storage_load():
print("\nTesting load_version_from_cloud")
try:
test = main.load_version_from_cloud(main.client, "test.json", "gtm-state-storage")
assert test == b"test data", f"test is {test}"
print("Load version passed")
except Exception as e:
print("Load version failed")
print(e)
if __name__ == "__main__":
try:
print("Tests started...")
test_get_data()
test_version()
test_cloud_storage_save()
test_cloud_storage_load()
except Exception as e:
print("Tests failed...")
print(e)