File size: 2,775 Bytes
8884f4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# =====================================================
# Apckeyl Framework
# Version 1.0
# run_example_compute_provider_test.py
# =====================================================

"""
Test runner for Example Compute Provider.

Version 1.0
"""

import traceback

from test_example_compute_provider import (
    test_get_provider_info,
    test_health_check,
    test_supports_task,
    test_execute_success,
    test_execute_missing_task_id,
    test_execute_missing_task_type,
    test_execute_unsupported_task,
)


# =====================================================
# Test Runner
# =====================================================

def main():

    tests = [
        (
            "test_get_provider_info",
            test_get_provider_info,
        ),
        (
            "test_health_check",
            test_health_check,
        ),
        (
            "test_supports_task",
            test_supports_task,
        ),
        (
            "test_execute_success",
            test_execute_success,
        ),
        (
            "test_execute_missing_task_id",
            test_execute_missing_task_id,
        ),
        (
            "test_execute_missing_task_type",
            test_execute_missing_task_type,
        ),
        (
            "test_execute_unsupported_task",
            test_execute_unsupported_task,
        ),
    ]

    passed = 0
    failed = 0

    print("=" * 60)
    print("APCKEYL FRAMEWORK")
    print("Example Compute Provider Test")
    print("Version 1.0")
    print("=" * 60)
    print()

    for test_name, test_function in tests:

        try:

            test_function()

            print(
                f"[PASS] {test_name}"
            )

            passed += 1

        except Exception as error:

            print(
                f"[FAIL] {test_name}"
            )

            print(
                f"       Error: {error}"
            )

            print(
                traceback.format_exc()
            )

            failed += 1

    print()
    print("=" * 60)
    print("TEST SUMMARY")
    print("=" * 60)

    print(
        f"Total:  {len(tests)}"
    )

    print(
        f"Passed: {passed}"
    )

    print(
        f"Failed: {failed}"
    )

    print("=" * 60)

    if failed == 0:

        print(
            "RESULT: PASSED"
        )

        return True

    print(
        "RESULT: FAILED"
    )

    return False


# =====================================================
# Direct Execution
# =====================================================

if __name__ == "__main__":

    success = main()

    if not success:

        raise SystemExit(1)


# =====================================================
# End of File
# =====================================================