Ejemplo n.º 1
0
def test_glider_information():
    headers = read_igc_headers([
        'AFLA6NG',
        'HFDTE',
        'HFGTYGLIDERTYPE:',
        'HFGIDGLIDERID:',
        'HFCIDCOMPETITIONID:'
    ])

    assert 'model' in headers
    assert headers['model'] == ''

    assert 'reg' in headers
    assert headers['reg'] == ''

    assert 'cid' in headers
    assert headers['cid'] == ''

    headers = read_igc_headers([
        'AFLA6NG',
        'HFDTE150812',
        'HFGTYGLIDERTYPE:HORNET',
        'HFGIDGLIDERID:D_4449',
        'HFCIDCOMPETITIONID:TH'
    ])

    assert 'model' in headers
    assert headers['model'] == 'HORNET'

    assert 'reg' in headers
    assert headers['reg'] == 'D_4449'

    assert 'cid' in headers
    assert headers['cid'] == 'TH'
Ejemplo n.º 2
0
def test_glider_information():
    assert_dict_contains_subset(
        dict(model='', reg='', cid=''),
        read_igc_headers(['AFLA6NG', 'HFDTE',
                          'HFGTYGLIDERTYPE:',
                          'HFGIDGLIDERID:',
                          'HFCIDCOMPETITIONID:']))

    assert_dict_contains_subset(
        dict(model='HORNET', reg='D_4449', cid='TH'),
        read_igc_headers(['AFLA6NG', 'HFDTE150812',
                          'HFGTYGLIDERTYPE:HORNET',
                          'HFGIDGLIDERID:D_4449',
                          'HFCIDCOMPETITIONID:TH']))
Ejemplo n.º 3
0
    def update_igc_headers(self):
        path = files.filename_to_path(self.filename)
        igc_headers = read_igc_headers(path)
        if igc_headers is None:
            return

        if "manufacturer_id" in igc_headers:
            self.logger_manufacturer_id = igc_headers["manufacturer_id"]

        if "logger_id" in igc_headers:
            self.logger_id = igc_headers["logger_id"]

        if "date_utc" in igc_headers:
            self.date_utc = igc_headers["date_utc"]

        if "model" in igc_headers and (
            igc_headers["model"] is None or 0 < len(igc_headers["model"]) < 64
        ):
            self.model = igc_headers["model"]

        if "reg" in igc_headers and (
            igc_headers["reg"] is None or 0 < len(igc_headers["reg"]) < 32
        ):
            self.registration = igc_headers["reg"]

        if "cid" in igc_headers and (
            igc_headers["cid"] is None or 0 < len(igc_headers["cid"]) < 5
        ):
            self.competition_id = igc_headers["cid"]
Ejemplo n.º 4
0
def test_simple_file():
    path = os.path.realpath(os.path.join(__file__, "..", "..", "data", "simple.igc"))

    assert read_igc_headers(path) == dict(
        manufacturer_id=u"XCS",
        logger_id=u"AAA",
        date_utc=datetime.date(2011, 6, 18),
        model=u"ASK13",
        reg=u"LY-KDR",
    )
Ejemplo n.º 5
0
def test_glider_information():
    headers = read_igc_headers(
        [
            b"AFLA6NG",
            b"HFDTE",
            b"HFGTYGLIDERTYPE:",
            b"HFGIDGLIDERID:",
            b"HFCIDCOMPETITIONID:",
        ]
    )

    assert "model" in headers
    assert headers["model"] == ""

    assert "reg" in headers
    assert headers["reg"] == ""

    assert "cid" in headers
    assert headers["cid"] == ""

    headers = read_igc_headers(
        [
            b"AFLA6NG",
            b"HFDTE150812",
            b"HFGTYGLIDERTYPE:HORNET",
            b"HFGIDGLIDERID:D_4449",
            b"HFCIDCOMPETITIONID:TH",
        ]
    )

    assert "model" in headers
    assert headers["model"] == "HORNET"

    assert "reg" in headers
    assert headers["reg"] == "D_4449"

    assert "cid" in headers
    assert headers["cid"] == "TH"
Ejemplo n.º 6
0
    def update_igc_headers(self):
        igc_headers = read_igc_headers(self.filename)

        if 'manufacturer_id' in igc_headers:
            self.logger_manufacturer_id = igc_headers['manufacturer_id']

        if 'logger_id' in igc_headers:
            self.logger_id = igc_headers['logger_id']

        if 'model' in igc_headers and 0 < len(igc_headers['model']) < 64:
            self.model = igc_headers['model']

        if 'reg' in igc_headers and 0 < len(igc_headers['reg']) < 32:
            self.registration = igc_headers['reg']
Ejemplo n.º 7
0
    def update_igc_headers(self):
        path = files.filename_to_path(self.filename)
        igc_headers = read_igc_headers(path)
        if igc_headers is None:
            return

        if 'manufacturer_id' in igc_headers:
            self.logger_manufacturer_id = igc_headers['manufacturer_id']

        if 'logger_id' in igc_headers:
            self.logger_id = igc_headers['logger_id']

        if 'date_utc' in igc_headers:
            self.date_utc = igc_headers['date_utc']

        if 'model' in igc_headers and 0 < len(igc_headers['model']) < 64:
            self.model = igc_headers['model']

        if 'reg' in igc_headers and 0 < len(igc_headers['reg']) < 32:
            self.registration = igc_headers['reg']

        if 'cid' in igc_headers and 0 < len(igc_headers['cid']) < 5:
            self.competition_id = igc_headers['cid']
Ejemplo n.º 8
0
def test_empty_file():
    eq_(read_igc_headers([]), {})
Ejemplo n.º 9
0
def test_date():
    assert_dict_contains_subset(
        dict(date_utc=datetime.date(2012, 8, 15)),
        read_igc_headers(['AFLA6NG', 'HFDTE150812']))
Ejemplo n.º 10
0
def test_date_only():
    assert_dict_equal(read_igc_headers(['HFDTE150812']),
                      dict(date_utc=datetime.date(2012, 8, 15)))
Ejemplo n.º 11
0
def test_logger_information():
    assert_dict_equal(read_igc_headers(['AFLA6NG']),
                      dict(manufacturer_id='FLA', logger_id='6NG'))
Ejemplo n.º 12
0
def test_filser_logger_id():
    assert_dict_equal(read_igc_headers(['AFIL01460FLIGHT:1']),
                      dict(manufacturer_id='FIL', logger_id='14K'))
Ejemplo n.º 13
0
def test_empty_file():
    assert read_igc_headers([]) == {}
Ejemplo n.º 14
0
def test_empty_file():
    eq_(read_igc_headers([]), {})
Ejemplo n.º 15
0
def test_logger_information():
    assert read_igc_headers([b"AFLA6NG"]) == dict(
        manufacturer_id="FLA", logger_id="6NG"
    )
Ejemplo n.º 16
0
def test_date():
    headers = read_igc_headers(['AFLA6NG', 'HFDTE150812'])

    assert 'date_utc' in headers
    assert headers['date_utc'] == datetime.date(2012, 8, 15)
Ejemplo n.º 17
0
def test_filser_logger_id():
    assert read_igc_headers([b"AFIL01460FLIGHT:1"]) == dict(
        manufacturer_id="FIL", logger_id="14K"
    )
Ejemplo n.º 18
0
def test_date():
    headers = read_igc_headers([b"AFLA6NG", b"HFDTE150812"])

    assert "date_utc" in headers
    assert headers["date_utc"] == datetime.date(2012, 8, 15)
Ejemplo n.º 19
0
def test_date_only():
    assert read_igc_headers([b"HFDTE150812"]) == dict(
        date_utc=datetime.date(2012, 8, 15)
    )