Exemplo n.º 1
0
def test_patch_config(session, headers):
    rand_target = random.randint(20, 30)
    rand_sensor_id = random.randint(0, 4)
    rand_external = random.randint(20, 50)
    rand_threshold = random.randint(1000, 2000)
    rand_min_rpm = random.randint(1, 20)
    rand_max_rpm = random.randint(21, 100)
    mode = 'asic'
    rand_restime = random.randint(50, 1000)
    rand_ontime = random.randint(50, 1000)
    rand_offtime = random.randint(50, 1000)
    rand_pidp = random.randint(0, 10)
    rand_pidi = random.randint(0, 20)
    rand_pidd = random.randint(0, 30)
    rand_pidb = random.randint(0, 40)

    data = {
        'target': rand_target,
        'sensor_id': rand_sensor_id,
        'external': rand_external,
        'threshold': rand_threshold,
        'min_rpm': rand_min_rpm,
        'max_rpm': rand_max_rpm,
        'proportional': rand_pidp,
        'integral': rand_pidi,
        'derivative': rand_pidd,
        'bias': rand_pidb,
        'active_mode': mode,
        'restime': rand_restime,
        'ontime': rand_ontime,
        'offtime': rand_offtime
    }
    session.patch(CONNECTION + '/cfg', data=data, headers=headers)
    resp = session.get(CONNECTION + '/cfg', headers=headers).json()
    assert assert_same_dict_content(data, resp)
Exemplo n.º 2
0
def test_patch_ventilation(session, headers):
    rand_min_rpm = random.randint(1, 20)
    rand_max_rpm = random.randint(21, 100)
    data = {'min_rpm': rand_min_rpm, 'max_rpm': rand_max_rpm}
    session.patch(CONNECTION + '/fans', data=data, headers=headers)
    resp = session.get(CONNECTION + '/fans', headers=headers).json()
    assert assert_same_dict_content(data, resp)
Exemplo n.º 3
0
def test_patch_operation_asic(session, headers):
    mode = 'asic'
    rand_restime = random.randint(50, 1000)
    data = {'active_mode': mode, 'restime': rand_restime}
    session.patch(CONNECTION + '/mode', data=data, headers=headers)
    resp = session.get(CONNECTION + '/mode', headers=headers).json()
    assert assert_same_dict_content(data, resp)
Exemplo n.º 4
0
def test_assert_same_dict_content_false():
    a = random.randint(0, 100)
    b = random.randint(0, 100)
    c = random.randint(0, 100)

    expected = {'a': a, 'b': b, 'c': c}
    given = {'a': a, 'b': b, 'c': -1, 'd': 4}
    assert assert_same_dict_content(expected, given) == False
Exemplo n.º 5
0
def test_patch_miner_on(session, headers):
    miner_id = str(random.randint(0, 119))
    action = 'register'
    session.patch(CONNECTION + '/miner?id=' + miner_id + '&' + 'action=' +
                  action,
                  headers=headers)
    resp = session.get(CONNECTION + '/miner?id=' + miner_id,
                       headers=headers).json()
    assert assert_same_dict_content({'running': True}, resp)
Exemplo n.º 6
0
def test_patch_miner_toggle(session, headers):
    miner_id = str(random.randint(0, 119))
    action = 'toggle'
    init_state = session.get(CONNECTION + '/miner?id=' + miner_id,
                             headers=headers).json()['running']
    session.patch(CONNECTION + '/miner?id=' + miner_id + '&' + 'action=' +
                  action,
                  headers=headers)
    resp = session.get(CONNECTION + '/miner?id=' + miner_id,
                       headers=headers).json()
    assert assert_same_dict_content({'running': not init_state}, resp)
Exemplo n.º 7
0
def test_patch_temperature(session, headers):
    rand_target = random.randint(20, 30)
    rand_sensor_id = random.randint(0, 4)
    rand_external = random.randint(20, 50)
    data = {
        'target': rand_target,
        'sensor_id': rand_sensor_id,
        'external': rand_external
    }
    session.patch(CONNECTION + '/temp', data=data)
    resp = session.get(CONNECTION + '/temp', headers=headers).json()
    assert assert_same_dict_content(data, resp)
Exemplo n.º 8
0
def test_put_PID(session, headers):
    rand_pidp = random.randint(0, 10)
    rand_pidi = random.randint(0, 20)
    rand_pidd = random.randint(0, 30)
    rand_pidb = random.randint(0, 40)
    data = {
        'proportional': rand_pidp,
        'integral': rand_pidi,
        'derivative': rand_pidd,
        'bias': rand_pidb
    }
    session.put(CONNECTION + '/pid', data=data, headers=headers)
    resp = session.get(CONNECTION + '/pid', headers=headers).json()
    assert assert_same_dict_content(data, resp)
Exemplo n.º 9
0
def test_patch_filtration(session, headers):
    rand_threshold = random.randint(1000, 2000)
    data = {'threshold': rand_threshold}
    session.patch(CONNECTION + '/filter', data=data, headers=headers)
    resp = session.get(CONNECTION + '/filter', headers=headers).json()
    assert assert_same_dict_content(data, resp)