aboutsummaryrefslogtreecommitdiffstats
path: root/moon_manager/tests/unit_python/api/utilities.py
blob: 66ca30c5c5948bbd3e6e9781ac7f1b77b1a98627 (plain)
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
import json


def get_json(data):
    return json.loads(data.decode("utf-8"))


def register_client():
    import moon_manager.server
    server = moon_manager.server.create_server()
    client = server.app.test_client()
    return client


def get_policy_id():
    import api.test_policies as policies
    client = register_client()
    policy_id = ''
    req, policy = policies.get_policies(client)
    for id in policy['policies']:
        if id:
            policy_id = id
            break
    if not policy_id:
        policies.add_policies(client, "testuser")
    return policy_id