示例#1
0
def test_all_df_rows_exist_in_create_columns_with_schema_map():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    entity_id = 'foo'
    i_query = InsertQuery(connection, ems_system, entity_id)

    dummy_df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c'], 'C': [4, 5, 6]})
    schema_map = {'A': '[-hub][A]', 'B': '[-hub][B]', 'C': '[-hub][C]'}
    i_query.insert_df(dummy_df, schema_map=schema_map)

    dummy_df = dummy_df.rename(columns=schema_map)
    create_columns = i_query.get_create_columns()
    create_columns = create_columns['createColumns']
    # Rows should have been added in order.
    i = 0
    for idx, row in dummy_df.iterrows():
        row_dict = row.to_dict()
        j = 0
        for item in row_dict.items():
            col = item[0]
            val = item[1]
            create_columns_entry = create_columns[i][j]
            assert (create_columns_entry['fieldId'] == col)
            assert (create_columns_entry['value'] == val)
            j = j + 1
        i = i + 1
示例#2
0
def test_one_profile_match_by_profile_number():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    profile = Profile(
        connection,
        ems_system,
        profile_number=108
    )  # one profile should match.
    assert profile._profile_name == 'Single Real Profile 2'
示例#3
0
def test_bad_profile_name_search():
    with pytest.raises(LookupError):
        ems_system = 'ems24-app'
        connection = MockConnection(user='', pwd='')
        profile = Profile(
            connection,
            ems_system,
            profile_name='A PROFILE THAT SHOULD NEVER EXIST'
        )   # no profiles should match.
示例#4
0
def test_no_profile_matches_by_profile_number():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    with pytest.raises(LookupError):
        # Obviously a profile that would never exist.
        profile = Profile(
            connection,
            ems_system,
            profile_number=1000000000000000000000000000
        )  # no profile should match.
示例#5
0
def test_excess_profile_matches_by_profile_name():
    with pytest.raises(LookupError):
        ems_system = 'ems24-app'
        connection = MockConnection(user='', pwd='')
        # There are multiple profiles with the name "Duplicate Profile" in the mocked data set.
        profile = Profile(
            connection,
            ems_system,
            profile_name='Duplicate Profile'
        )
示例#6
0
def test_name_search_returns_shortest():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    profile = Profile(
        connection,
        ems_system,
        profile_name='Single Real Profile',
        searchtype='contain'
    )
    assert profile._profile_name == 'Single Real Profile'
示例#7
0
def test_profile_attributes_by_profile_number():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    profile = Profile(
        connection,
        ems_system,
        profile_number=88
    )  # one profile should match.
    assert profile._profile_name == 'Duplicate Profile'
    assert profile._guid == '5b8dc8cb-c8cb-c8cb-c8cb-c8cb39e6c8cb'
    assert profile._current_version == 9
    assert profile._library == True
    assert profile._local_id == 88
示例#8
0
def test_profile_attributes_by_profile_name():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    # one profile should match
    profile = Profile(
        connection,
        ems_system,
        profile_name='Single Profile 3'
    )
    assert profile._profile_name == 'Single Profile 3'
    assert profile._guid == 'f163eeee-63ee-63ee-63ee-1b363eed63ee'
    assert profile._current_version == 8
    assert profile._library == True
    assert profile._local_id == 56
示例#9
0
def test_all_create_columns_exist_in_df_without_schema_map():
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    entity_id = 'foo'
    i_query = InsertQuery(connection, ems_system, entity_id)

    dummy_df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c'], 'C': [4, 5, 6]})
    i_query.insert_df(dummy_df)

    create_columns = i_query.get_create_columns()
    create_columns = create_columns['createColumns']
    # Rows should have been added in order.
    i = 0
    for row in create_columns:
        row_df = dummy_df.iloc[i, :]  # create_column row # should correspond to dataframe row #
        j = 0
        for item in row:
            fieldId = item['fieldId']
            value = item['value']
            assert (value == row_df[fieldId])
            j = j + 1
        i = i + 1
示例#10
0
def MockFilterQuery(field, dbname=os.path.join(test_path, 'mock_metadata.db')):
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    query = MockFltQuery(connection, ems_system, data_file=dbname)
    query.set_database('FDW Flights')
    query.update_fieldtree(
        'Aircraft Information',
        exclude_tree=[
            'Airframe Information',
            'Engine Information',
            'Fleet Information'
        ]
    )
    query.update_fieldtree(
        'Flight Information',
        exclude_tree=[
            'Processing',
            'Date Times',
            'FlightPulse'
        ]
    )
    query.select(field)
    return query
示例#11
0
def query():
    c = MockConnection(user='', pwd='')
    ems = MockEMS(c)
    AirportQuery = Airport(c, ems.get_id())
    return AirportQuery
示例#12
0
def query():
    c = MockConnection(user='', pwd='')
    FlightPhaseQuery = FlightPhase(c)
    return FlightPhaseQuery
示例#13
0
def tsq_no_db(mocks):
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    return emspy.query.TSeriesQuery(connection, ems_system, data_file=None)
示例#14
0
def tsq(mocks):
    ems_system = 'ems24-app'
    connection = MockConnection(user='', pwd='')
    data_file = get_test_db_path()
    return emspy.query.TSeriesQuery(connection, ems_system, data_file)