示例#1
0
def test_window_type_day_zero_value(window_aggregate: WindowAggregate) -> None:
    window_aggregate._schema.window_type = Type.DAY
    window_aggregate._schema.window_value = 0
    with pytest.raises(PrepareWindowMissingBlocksError,
                       match='No matching blocks found'):
        window_aggregate._prepare_window(
            datetime(2018, 3, 7, 21, 36, 31, 0, timezone.utc))
    assert window_aggregate._window_source.events == []
示例#2
0
def test_window_type_count_missing_sesssions(window_aggregate: WindowAggregate) -> None:
    window_aggregate._schema.window_type = Type.COUNT
    window_aggregate._schema.window_value = 20
    with pytest.raises(
            PrepareWindowMissingBlocksError,
            match='test_window_name WindowAggregate: Expecting 20 but found 3 blocks'):
        window_aggregate._prepare_window(datetime(2018, 3, 7, 21, 36, 31, 0, timezone.utc))
    assert window_aggregate._window_source.events == [4, 5, 6]
示例#3
0
def test_window_type_day_positive(window_aggregate: WindowAggregate) -> None:
    window_aggregate._schema.window_type = Type.DAY
    window_aggregate._schema.window_value = 1
    window_aggregate._prepare_window(
        datetime(2018, 3, 7, 21, 36, 31, 0, timezone.utc))
    assert window_aggregate._window_source.events == [4, 5]
示例#4
0
def window_aggregate(
        window_aggregate_schema: WindowAggregateSchema) -> WindowAggregate:
    return WindowAggregate(window_aggregate_schema, "user1",
                           EvaluationContext(Context({'identity': 'user1'})))
示例#5
0
def test_window_type_hour_negative(window_aggregate: WindowAggregate) -> None:
    window_aggregate._schema.window_type = Type.HOUR
    window_aggregate._schema.window_value = -24
    window_aggregate._prepare_window(
        datetime(2018, 3, 7, 21, 36, 31, 0, timezone.utc))
    assert window_aggregate._window_source.events == [1, 2]