Пример #1
0
def test_read_map(one_map_file, one_map_file_data):
    inx = IonexV1(one_map_file)

    # FIXME: в фикстуры
    epoch = datetime(1999, 1, 2, 1, 0, 0)
    height = 450.0
    result = Map(epoch=epoch, height=height, data=one_map_file_data)

    # находимся в начале файла: промотаем до начала карты
    line = ''
    with inx._context_manager as file_object:
        for _ in range(19):
            line = next(file_object)
        assert line == '''\
     1                                                      START OF TEC MAP
'''
        assert result == inx._read_map(file_object)
Пример #2
0
def test_read_header(ionex_header, lon_def, lat_def, hgt_def, grid_def):
    inx = IonexV1(ionex_header)
    with inx._context_manager as file_object:
        inx._read_header(file_object)

        # ожидаемые атрибуты
        assert inx.exponent == -1
        assert inx.dimension == 2

        assert inx.latitude == lat_def
        assert inx.longitude == lon_def
        assert inx.height == hgt_def

        assert inx.grid == grid_def

        # прервались сразу после заголовка
        line = next(file_object)
        assert line == (
            '     1                                                   '
            '   START OF TEC MAP\n')
Пример #3
0
def test_parse_epoch(epoch_str, dt, ionex_file):
    inx = IonexV1(ionex_file)
    assert dt == inx._parse_epoch(epoch_str)
Пример #4
0
def test_coerce_to_int_error(ionex_file):
    inx = IonexV1(ionex_file)
    with pytest.raises(ValueError):
        inx._coerce_into_int('hello')
Пример #5
0
def test_coerce_to_int(value, expected):
    assert expected == IonexV1._coerce_into_int(value)
Пример #6
0
def test_reader_no_end_of_file(ionex_file_no_end_of_file):
    inx = IonexV1(ionex_file_no_end_of_file)
    with pytest.warns(UserWarning, match='Unexpected end of the file'):
        for _ in inx:
            pass
    assert inx._tec_maps_numbers == list(range(1, 13))
Пример #7
0
def test_reader(ionex_file):
    inx = IonexV1(ionex_file)
    # имитируем чтение
    for _ in inx:
        pass
    assert inx._tec_maps_numbers == list(range(1, 13))
Пример #8
0
def test_read_slice(line, result):
    assert result == IonexV1._read_slice(line)
Пример #9
0
def test_parse_map_grid_def(grid_def_str, result):
    assert result == IonexV1._parse_map_grid_def(grid_def_str)