~panda-roux/MoonGem

MoonGem/test/test_definitions.py -rw-r--r-- 502 bytes
fc5c595e — panda-roux adding -p to mkdir 29 days 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()