~panda-roux/MoonGem

ref: a4ed647ebba6359cf5082866996636ceb78f0fa3 MoonGem/test/test_definitions.py -rw-r--r-- 502 bytes
a4ed647e — panda-roux adding benchmarks 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(f'Response was {response.data()}')
    return ok()