Пример #1
0
def test__MeasurementQuery__is_consumption__Measurement_exists__returns_correct_Measurements(seeded_session):
    query = MeasurementQuery(seeded_session) \
        .is_consumption()

    assert query.count() > 0
    assert all(m.type == MeasurementType.CONSUMPTION for m in query.all())
Пример #2
0
def test__MeasurementQuery__is_published__Measurement_exists__returns_correct_Measurements(seeded_session, is_published):
    query = MeasurementQuery(seeded_session) \
        .is_published(is_published)

    assert query.count() > 0
    assert all(m.published == is_published for m in query.all())
Пример #3
0
def test__MeasurementQuery__has_any_gsrn__Measurement_does_not_exist__returs_nothing(seeded_session):
    query = MeasurementQuery(seeded_session) \
        .has_any_gsrn(['a GSRN not present in the database', 'another'])

    assert query.count() == 0
    assert query.one_or_none() is None
Пример #4
0
def test__MeasurementQuery__is_type__Measurement_exists__returns_correct_Measurements(seeded_session, type):
    query = MeasurementQuery(seeded_session) \
        .is_type(type)

    assert query.count() > 0
    assert all(m.type == type for m in query.all())
Пример #5
0
def test__MeasurementQuery__has_id__Measurement_does_not_exist__returs_nothing(seeded_session, measurement_id):
    query = MeasurementQuery(seeded_session) \
        .has_id(measurement_id)

    assert query.count() == 0
    assert query.one_or_none() is None
Пример #6
0
def test__MeasurementQuery__has_any_gsrn__Measurement_exists__returns_correct_Measurements(seeded_session, gsrn):
    query = MeasurementQuery(seeded_session) \
        .has_any_gsrn(gsrn)

    assert query.count() > 0
    assert all(m.gsrn in gsrn for m in query.all())
Пример #7
0
def test__MeasurementQuery__begins_within__Measurement_does_not_exist__returs_nothing(seeded_session, begin, end):
    query = MeasurementQuery(seeded_session) \
        .begins_within(DateTimeRange(begin=begin, end=end))

    assert query.count() == 0
Пример #8
0
def test__MeasurementQuery__has_id__Measurement_exists__returns_correct_Measurement(seeded_session, measurement_id):
    query = MeasurementQuery(seeded_session) \
        .has_id(measurement_id)

    assert query.count() == 1
    assert query.one().id == measurement_id
Пример #9
0
def test__MeasurementQuery__begins_within__returns_correct_measurements(seeded_session, begin, end):
    query = MeasurementQuery(seeded_session) \
        .begins_within(DateTimeRange(begin=begin, end=end))

    assert query.count() > 0
    assert all(begin <= m.begin <= end for m in query.all())
Пример #10
0
def test__MeasurementQuery__begins_at__Measurement_does_not_exist__returs_nothing(seeded_session, begin):
    query = MeasurementQuery(seeded_session) \
        .begins_at(begin)

    assert query.count() == 0
Пример #11
0
def test__MeasurementQuery__begins_at__returns_correct_measurements(seeded_session, begin):
    query = MeasurementQuery(seeded_session) \
        .begins_at(begin)

    assert query.count() > 0
    assert all(m.begin == begin for m in query.all())
Пример #12
0
def test__MeasurementQuery__belongs_to__Measurement_does_not_exist__returs_nothing(seeded_session):
    query = MeasurementQuery(seeded_session) \
        .belongs_to('a subject that does not exists')

    assert query.count() == 0
Пример #13
0
def test__MeasurementQuery__belongs_to__returns_correct_measurements(seeded_session, sub):
    query = MeasurementQuery(seeded_session) \
        .belongs_to(sub)

    assert query.count() > 0
    assert all(m.sub == sub for m in query.all())