-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_swift_sdk.py
59 lines (40 loc) · 2.56 KB
/
test_swift_sdk.py
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
#!/usr/bin/python3
import os
from genezio import genezio_deploy, genezio_login, genezio_local, genezio_delete
from os.path import exists
from utils import kill_process
def test_swift_sdk():
print("Starting swift sdk test...")
token = os.environ.get('GENEZIO_TOKEN')
if os.path.exists("./projects/swift-sdk/client") is False:
os.makedirs("./projects/swift-sdk/client")
genezio_login(token)
os.chdir("./projects/swift-sdk/")
deploy_result = genezio_deploy(False)
assert deploy_result.return_code == 0, "genezio deploy returned non-zero exit code"
assert deploy_result.project_url != "", "genezio deploy returned empty project url"
assert exists("./client/sdk/remote.swift") == True, "Remote swift sdk not found"
assert exists("./client/sdk/server.sdk.swift") == True, "Class swift sdk not found"
with open("./client/sdk/server.sdk.swift", "r", encoding="utf-8") as f:
content = f.read()
assert "static func method() async -> Any" in content, "Wrong exported method without parameters"
assert "static func methodWithoutParameters() async -> String" in content, "Wrong exported method with return type"
assert "static func methodWithOneParameter(test1: String) async -> String" in content, "Wrong exported method with one parameter"
assert "static func methodWithMultipleParameters(test1: String, test2: Double) async -> String" in content, "Wrong exported method with multiple parameters"
process = genezio_local()
assert process != None, "genezio local returned None"
assert exists("./client/sdk/remote.swift") == True, "Remote swift sdk not found"
assert exists("./client/sdk/server.sdk.swift") == True, "Class swift sdk not found"
with open("./client/sdk/server.sdk.swift", "r", encoding="utf-8") as f:
content = f.read()
assert "static func method() async -> Any" in content, "Wrong exported method without parameters"
assert "static func methodWithoutParameters() async -> String" in content, "Wrong exported method with return type"
assert "static func methodWithOneParameter(test1: String) async -> String" in content, "Wrong exported method with one parameter"
assert "static func methodWithMultipleParameters(test1: String, test2: Double) async -> String" in content, "Wrong exported method with multiple parameters"
kill_process(process)
print("Prepared to delete project...")
genezio_delete(deploy_result.project_id)
print("Test passed!")
# Test order matters because the commands are having side effects.
if __name__ == '__main__':
test_swift_sdk()