Example #1
0
def test_dateTime_dateTimeRange():
    # Not implemented, but it exists as an option in the API
    query = MockFilterQuery('Flight Date (Exact)')
    with pytest.raises(ValueError):
        query.filter(
            "'2019-01-01 00:00:00+00:00' <= 'Flight Date (Exact)' <= '2020-01-01 00:00:00+00:00'"
        )
Example #2
0
def test_discrete_isNotNull():
    query = MockFilterQuery('Flight Date Confidence')
    query.filter("'Flight Date Confidence' is not null")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'isNotNull'
    assert len(queryset_filter['args']) == 1
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.date-confidence]]]'
    }
Example #3
0
def test_boolean_isNotNull():
    query = MockFilterQuery('Takeoff Valid')
    query.filter("'Takeoff Valid' is not null")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'isNotNull'
    assert len(queryset_filter['args']) == 1
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.exist-takeoff]]]'
    }
Example #4
0
def test_number_isNull():
    query = MockFilterQuery('Flight Record')
    query.filter("'Flight Record' is null")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'isNull'
    assert len(queryset_filter['args']) == 1
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.uid]]]'
    }
Example #5
0
def test_string_isNotNull():
    query = MockFilterQuery('Flight Number String')
    query.filter("'Flight Number String' is not null")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'isNotNull'
    assert len(queryset_filter['args']) == 1
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.flight-num-str]]]'
    }
Example #6
0
def test_dateTime_isNotNull():
    # Not implemented, but it exists as an option in the API
    query = MockFilterQuery('Flight Date (Exact)')
    query.filter("'Flight Date (Exact)' is not null")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'isNotNull'
    assert len(queryset_filter['args']) == 1
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.exact-date]]]'
    }
Example #7
0
def test_discrete_lessThanOrEqual():
    query = MockFilterQuery('Flight Date Confidence')
    query.filter("'Flight Date Confidence' <= 'Low'")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'lessThanOrEqual'
    assert len(queryset_filter['args']) == 2
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.date-confidence]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': 1
    }
Example #8
0
def test_number_lessThanOrEqual():
    query = MockFilterQuery('Flight Record')
    query.filter("'Flight Record' <= '17000'")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'lessThanOrEqual'
    assert len(queryset_filter['args']) == 2
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.uid]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': '17000'
    }
Example #9
0
def test_string_notEqual():
    query = MockFilterQuery('Flight Number String')
    query.filter("'Flight Number String' != '000000000'")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'notEqual'
    assert len(queryset_filter['args']) == 2
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.flight-num-str]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': '000000000'
    }
Example #10
0
def test_dateTime_dateTimeOnAfter():
    query = MockFilterQuery('Flight Date (Exact)')
    query.filter("'Flight Date (Exact)' >= '2020-01-01 00:00:00+00:00'")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'dateTimeOnAfter'
    assert len(queryset_filter['args']) == 3
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.exact-date]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': '2020-01-01 00:00:00+00:00'
    }
    assert queryset_filter['args'][2] == {
        'type': 'constant',
        'value': 'Utc'
    }
Example #11
0
def test_number_notBetweenInclusive():
    query = MockFilterQuery('Flight Record')
    query.filter("'15000' >= 'Flight Record' >= '17000'")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'notBetweenInclusive'
    assert len(queryset_filter['args']) == 3
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.uid]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': '15000'
    }
    assert queryset_filter['args'][2] == {
        'type': 'constant',
        'value': '17000'
    }
Example #12
0
def test_discrete_notIn():
    query = MockFilterQuery('Flight Date Confidence')
    query.filter("'Flight Date Confidence' not in ['Unknown', 'Low']")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'notIn'
    assert len(queryset_filter['args']) == 3
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.date-confidence]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': 0
    }
    assert queryset_filter['args'][2] == {
        'type': 'constant',
        'value': 1
    }
Example #13
0
def test_number_notIn():
    query = MockFilterQuery('Flight Record')
    query.filter("'Flight Record' not in ['17000', '17001', '17002']")
    queryset_filter = get_filter(query)
    assert queryset_filter['operator'] == 'notIn'
    assert len(queryset_filter['args']) == 4
    assert queryset_filter['args'][0] == {
        'type': 'field',
        'value': '[-hub-][field][[[ems-core][entity-type][foqa-flights]]'
                 '[[ems-core][base-field][flight.uid]]]'
    }
    assert queryset_filter['args'][1] == {
        'type': 'constant',
        'value': '17000'
    }
    assert queryset_filter['args'][2] == {
        'type': 'constant',
        'value': '17001'
    }
    assert queryset_filter['args'][3] == {
        'type': 'constant',
        'value': '17002'
    }
Example #14
0
def test_legacyDB_kvmaps():
    create_tmpDB(legacy=True)
    query = MockFilterQuery('Engine Series', 'tmpDB.db')
    kvmaps = query._FltQuery__flight._Flight__get_kvmaps()
    assert_tree(query, kvmaps, legacy=True)
Example #15
0
def test_legacyDB_dbtree():
    create_tmpDB(legacy=True)
    query = MockFilterQuery('Engine Series', 'tmpDB.db')
    dbtree = query._FltQuery__flight._Flight__get_dbtree()
    assert_tree(query, dbtree, legacy=True)
Example #16
0
def test_dateTime_unsupported():
    query = MockFilterQuery('Flight Date (Exact)')
    with pytest.raises(ValueError):
        query.filter("'Flight Date (Exact)' == '2020-01-01 00:00:00+00:00'")
    with pytest.raises(ValueError):
        query.filter("'Flight Date (Exact)' != '2020-01-01 00:00:00+00:00'")
    with pytest.raises(ValueError):
        query.filter("'Flight Date (Exact)' > '2020-01-01 00:00:00+00:00'")
    with pytest.raises(ValueError):
        query.filter("'Flight Date (Exact)' <= '2020-01-01 00:00:00+00:00'")
    with pytest.raises(ValueError):
        query.filter(
            "'2019-01-01 00:00:00+00:00' < 'Flight Date (Exact)' < '2020-01-01 00:00:00+00:00'"
        )
Example #17
0
def test_discrete_unsupported():
    query = MockFilterQuery('Flight Date Confidence')
    with pytest.raises(ValueError):
        query.filter("'Unknown' < 'Flight Date Confidence' < 'High'")
Example #18
0
def test_boolean_unsupported():
    query = MockFilterQuery('Takeoff Valid')
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' == '0'")
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' == '1'")
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' > True")
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' < True")
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' >= True")
    with pytest.raises(ValueError):
        query.filter("'Takeoff Valid' <= True")
    with pytest.raises(ValueError):
        query.filter("True < 'Takeoff Valid' < False")
Example #19
0
def test_string_unsupported():
    query = MockFilterQuery('Flight Number String')
    with pytest.raises(ValueError):
        query.filter("'Flight Number String' > '000000000'")
    with pytest.raises(ValueError):
        query.filter("'Flight Number String' < '000000000'")
    with pytest.raises(ValueError):
        query.filter("'Flight Number String' >= '000000000'")
    with pytest.raises(ValueError):
        query.filter("'Flight Number String' <= '000000000'")
    with pytest.raises(ValueError):
        query.filter("'000000000' < 'Flight Number String' < '000000000'")
    with pytest.raises(ValueError):
        query.filter("'000000000' <= 'Flight Number String' <= '000000000'")
    with pytest.raises(ValueError):
        query.filter("'000000000' > 'Flight Number String' > '000000000'")
    with pytest.raises(ValueError):
        query.filter("'000000000' >= 'Flight Number String' >= '000000000'")