Esempio n. 1
0
class TestPosition(TestCase):
    def setUp(self):
        self.x = Position(datetime.time(14, 20, 58), True, 53.1440233333,
                          -3.01542833333, 109394.7, 202.9,
                          datetime.date(2007, 11, 19), 5.0)

    def test___repr__(self):
        expect(repr(self.x)) == \
            ('Position(datetime.time(14, 20, 58), True, 53.1440233333, '
             '-3.01542833333, 109394.7, 202.9, datetime.date(2007, 11, 19), '
             '5.0, None)')

    def test___str__(self):
        expect(str(self.x)) == \
            '$GPRMC,142058,A,5308.6414,N,00300.9257,W,109394.7,202.9,191107,5,E*41\r'

    def test_mode_string(self):
        expect(str(self.x.mode_string())) == 'Unknown'
        self.x.mode = 'A'
        expect(str(self.x.mode_string())) == 'Autonomous'

    def test_parse_elements(self):
        expect(repr(Position.parse_elements(['142058', 'A', '5308.6414', 'N',
                                            '00300.9257', 'W', '109394.7',
                                            '202.9', '191107', '5', 'E', 'A']))) == \
            ('Position(datetime.time(14, 20, 58), True, %s, %s, 109394.7, '
             "202.9, datetime.date(2007, 11, 19), 5.0, 'A')"
             % (53.14402333333334, -3.0154283333333334))
        expect(repr(Position.parse_elements(['142100', 'A', '5200.9000', 'N',
                                            '00316.6600', 'W', '123142.7',
                                            '188.1', '191107', '5', 'E', 'A']))) == \
            ('Position(datetime.time(14, 21), True, 52.015, %s, 123142.7, '
             "188.1, datetime.date(2007, 11, 19), 5.0, 'A')"
             % (-3.2776666666666667))
Esempio n. 2
0
 def test_parse_elements(self):
     expect(repr(Position.parse_elements(['142058', 'A', '5308.6414', 'N',
                                         '00300.9257', 'W', '109394.7',
                                         '202.9', '191107', '5', 'E', 'A']))) == \
         ('Position(datetime.time(14, 20, 58), True, %s, %s, 109394.7, '
          "202.9, datetime.date(2007, 11, 19), 5.0, 'A')"
          % (53.14402333333334, -3.0154283333333334))
     expect(repr(Position.parse_elements(['142100', 'A', '5200.9000', 'N',
                                         '00316.6600', 'W', '123142.7',
                                         '188.1', '191107', '5', 'E', 'A']))) == \
         ('Position(datetime.time(14, 21), True, 52.015, %s, 123142.7, '
          "188.1, datetime.date(2007, 11, 19), 5.0, 'A')"
          % (-3.2776666666666667))
Esempio n. 3
0
 def setUp(self):
     self.x = Position(datetime.time(14, 20, 58), True, 53.1440233333,
                       -3.01542833333, 109394.7, 202.9,
                       datetime.date(2007, 11, 19), 5.0)