Exemple #1
0
def test_store_new_valid(reset_db, default_init):
    # Test when TrackedProgram is valid
    DataManager.store_new(default_init)
    result = DataManager.query("SELECT * FROM program_log", single=True)

    assert result['start_time'] == default_init.start_time
    assert result['end_time'] == default_init.end_time
    assert result['time_left'] == default_init.time_left
    assert result['max_time'] == default_init.max_time
    assert result['name'] == default_init.name
    assert result['id'] is 1
Exemple #2
0
def test_update_pg(reset_db, default_init):
    start_time = 10
    end_time = 20

    DataManager.store_new(default_init)
    id = DataManager.id_of_obj(default_init)
    DataManager.update_pg(id, start_time=start_time, end_time=end_time)
    from_db = DataManager.get(name=default_init.name)

    assert from_db.start_time != default_init.start_time
    assert from_db.end_time != default_init.end_time
    assert from_db.start_time == start_time
    assert from_db.end_time == end_time
Exemple #3
0
def test_get_day(reset_db, date_fixture):
    base, date1, date2, date3 = date_fixture['date_objs']
    test1, test2, test3, test4 = date_fixture['test_objs']
    offset = 1000

    # Test getting a single days result
    day_results = DataManager.get_day(base)
    assert [test1] == day_results

    day_results = DataManager.get_day(date1)
    assert [test2] == day_results

    # Tests with a filtering argument
    day_results = DataManager.get_day(base, name="test5")
    assert [] == day_results

    # Getting multiple objects that are in the same day
    test5 = TrackedProgram("test5", 10,
                           base.timestamp() + offset,
                           base.timestamp() + 2 * offset, 10)
    DataManager.store_new(test5)

    day_results = DataManager.get_day(base)
    assert [test1, test5] == day_results
Exemple #4
0
def test_id_of_obj(reset_db, default_init):
    DataManager.store_new(default_init)
    assert DataManager.id_of_obj(default_init) == 1
Exemple #5
0
def test_get(reset_db, default_init):
    DataManager.store_new(default_init)
    result = DataManager.get(name=default_init.name)
    assert result == default_init