~panda-roux/MoonGem

ref: fee4c7c3300f74d8444be03923034bd4973258aa MoonGem/test/test_definitions.py -rw-r--r-- 489 bytes
fee4c7c3 — panda-roux adding a testing framework 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import ignition as ig
from ignition.response import BaseResponse

def fail(msg):
    return False, msg

def ok():
    return True, None

def exists(response: BaseResponse):
    if response.status == ig.RESPONSE_STATUSDETAIL_PERM_FAILURE_NOT_FOUND:
        return fail('Resource was not found')
    return ok()

def does_not_exist(response: BaseResponse):
    if response.status != ig.RESPONSE_STATUSDETAIL_PERM_FAILURE_NOT_FOUND:
        return fail('Resource was found')
    return ok()