Skip to content

Commit

Permalink
Remove line length limit (#30)
Browse files Browse the repository at this point in the history
* remove unused error

* remove maximum line length

* add check on invalid B records

* fix flake8
  • Loading branch information
GliderGeek authored and Turbo87 committed Mar 30, 2018
1 parent f165dc4 commit 86996ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
12 changes: 0 additions & 12 deletions aerofiles/igc/reader.py
Expand Up @@ -167,10 +167,6 @@ def next(self):
yield (record_type, None, e)

def parse_line(self, record_type, line):

if len(line) > 76:
raise LineLengthError

decoder = self.get_decoder_method(record_type)
return decoder(line)

Expand Down Expand Up @@ -691,17 +687,9 @@ def decode_longitude(lon_string):
return longitude


class InvalidIGCFileError(Exception):
pass


class MissingRecordsError(Exception):
pass


class MissingExtensionsError(Exception):
pass


class LineLengthError(Exception):
pass
24 changes: 24 additions & 0 deletions tests/igc/test_reader.py
@@ -1,6 +1,10 @@
# This Python file uses the following encoding: utf-8

import datetime
import os

import pytest

from aerofiles.igc.reader import Reader
from aerofiles.igc.reader import LowLevelReader

Expand Down Expand Up @@ -32,6 +36,26 @@ def test_decode_B_record():
assert LowLevelReader.decode_B_record(line) == expected_result


def test_decode_invalid_B_record():
"""Test whether decoding invalid B record raise Error"""

invalid_b_records = [
'B1053175438931N0ÿÿÿøÈÐÀÀÜÐáÀÄÈàÔÀÄÈÌØÀÀÜÀÀ',
'BÿÿÿøÄÀÈÌÄàÐäÐàààÁ8ÀÄÔÀäÈÌå��ÀÄàÔäÀ',
'B1140ÿÿÿøÌÈÔÐÌÌààÑ8ÀÈÐÈÌàÌÕÀÀääÈÀÀäÔ',
'B1309044931600N0153ÿÿÿøÐÀÄÍÀÄÔÌØÀÄÔÜØÀÀäÀ',
'B10470349ÿÿÿøÌÔäØÕ8ÀÄÔÄÈàÜÙÀÄàÐÐÀÄäÀÜÀÀØÀ',
'B11052249474ÿÿÿøÀÉ8ÀÄÔÀÜÜäÕÀÄÌÐÌÀÄÐÀÈÀÀÔÀ',
'B12ÿÿÿøÐØÀÌÐäÐÈØäÝ8ÀÄÔÄÜÌÐÑÀÄØÐàÀÄÜÐÀÀÀÜÀÀÀ4)ÄÈ',
'B1124185148269N9833N00553309EA0084800873000068000000',
'B1245085122369N00614242EÿÿÿùÀÄÜØÄÀÄàÐäÀÀØÀ',
]

for b_record in invalid_b_records:
with pytest.raises(ValueError):
LowLevelReader.decode_B_record(b_record)


def test_decode_C_record1():
line = 'C150701213841160701000102 500K Tri\r\n'
expected_result = {
Expand Down

0 comments on commit 86996ab

Please sign in to comment.