Пример #1
0
def test_add(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    # Create new alerts
    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    # Add one alert
    alerts.add_alert(id, type, bound, direction)

    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[
        0].direction == operator.gt if direction == 'gt' else operator.lt

    # Try adding again
    alerts.add_alert(id, type, bound, direction)

    # Nothing should have changed
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[
        0].direction == operator.gt if direction == 'gt' else operator.lt
Пример #2
0
def test_alerts(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    alerts.add_alert(id, type, bound, direction)
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[
        0].direction == operator.gt if direction == 'gt' else operator.lt

    a = alerts.get_alerts()
    assert (len(a['alerts']) == 1)
    assert a['alerts'][0]['id'] == id
    assert a['alerts'][0]['type'] == type
    assert a['alerts'][0]['bound'] == bound
    assert a['alerts'][0]['direction'] == direction
Пример #3
0
def test_add(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    # Create new alerts
    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    # Add one alert
    alerts.add_alert(id, type, bound, direction)

    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[0].direction == operator.gt if direction == 'gt' else operator.lt

    # Try adding again
    alerts.add_alert(id, type, bound, direction)

    # Nothing should have changed
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[0].direction == operator.gt if direction == 'gt' else operator.lt
Пример #4
0
def test_alerts(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    alerts.add_alert(id, type, bound, direction)
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[0].direction == operator.gt if direction == 'gt' else operator.lt

    a = alerts.get_alerts()
    assert(len(a['alerts']) == 1)
    assert a['alerts'][0]['id'] == id
    assert a['alerts'][0]['type'] == type
    assert a['alerts'][0]['bound'] == bound
    assert a['alerts'][0]['direction'] == direction
Пример #5
0
def test_add_and_delete(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    alerts.add_alert(id, type, bound, direction)
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[0].direction == operator.gt if direction == 'gt' else operator.lt

    alerts.delete_alert(id, type, bound, direction)
    assert len(alerts.alerts) == 0
Пример #6
0
def test_clear(fb):
    id = "test@test"
    type = "temperature"
    bound = 80
    direction = "gt"

    # Delete everything
    fb.delete(dummy_database, None)

    alerts = Alerts(lambda x: x, dummy_database)
    assert len(alerts.alerts) == 0

    alerts.add_alert(id, type, bound, direction)
    assert len(alerts.alerts) == 1
    assert alerts.alerts.ix[0].id == id
    assert alerts.alerts.ix[0].type == type
    assert alerts.alerts.ix[0].bound == bound
    assert alerts.alerts.ix[
        0].direction == operator.gt if direction == 'gt' else operator.lt

    alerts.clear_alerts()
    assert len(alerts.alerts) == 0