Example #1
0
def test_admin_set_cal_at(login):
    on_at = '22:22'
    off_at = '01:22'
    res = utils.call('PATCH',
                     url='/b/admin/cal/2017-10-07',
                     json={
                         'on': on_at,
                         'off': off_at
                     },
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)

    res = res.json()
    assert isinstance(res['on'], (str, unicode))
    assert isinstance(res['off'], (str, unicode))
    assert res['on'] == on_at
    assert res['off'] == off_at

    res = utils.call('PATCH',
                     url='/b/admin/cal/2017-10-07',
                     json={
                         'on': '19:08',
                         'off': '04:31'
                     },
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)
Example #2
0
def test_admin_set_enabled_true(login):
    res = utils.call('POST',
                     url='/b/admin/enabled',
                     json={'enabled': True},
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)
    res = res.json()
    assert res['enabled'] == True
Example #3
0
def test_admin_login():
    res = utils.call('POST', url='/b/login', json=Settings.ADMIN)
    assert utils.is_status_ok(res.status_code)

    res = res.json()

    assert res['login']
    assert len(res['token']) > 32
Example #4
0
def test_admin_apps_list(login):
    res = utils.call('GET',
                     url='/b/apps',
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)

    res = res.json()
    assert isinstance(res, list)
Example #5
0
def test_admin_cal(login):
    res = utils.call('GET',
                     url='/b/admin/cal',
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)

    res = res.json()
    print(res)
    assert isinstance(res['on'], (str, unicode))
    assert isinstance(res['off'], (str, unicode))
Example #6
0
def test_admin_current_app(login):
    res = utils.call('GET',
                     url='/b/apps/running',
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)
    res = res.json()
    assert isinstance(res, dict)
    if res:
        assert 'name' in res
        assert res['started_at']
        assert 'params' in res
        assert 'username' in res
Example #7
0
def test_user_app_set():
    login = utils.call('POST', url='/b/login',
                       json=Settings.USER).json()['token']
    params = {'uapp': 'swipe', 'colors': ['pink']}
    res = utils.call('POST',
                     url='/b/apps/running',
                     json={
                         'name': 'Flags',
                         'params': {
                             "uapp": "spain"
                         },
                         'expires': 20
                     },
                     headers={'Authorization': 'Bearer ' + login})
    assert utils.is_status_ok(res.status_code)
Example #8
0
def test_admin_respond_200():
    assert utils.is_status_ok(
        utils.call('GET', url='/status/is_up').status_code)