Code Duplication    Length = 30-32 lines in 2 locations

tests/test_util.py 2 locations

@@ 104-135 (lines=32) @@
101
102
    def test_longitude_west(self):
103
        """Test Decimal to APRS Longitude conversion.
104
105
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
106
        --
107
        Longitude is expressed as a fixed 9-character field, in degrees and
108
        decimal minutes (to two decimal places), followed by the letter E for
109
        east or W for west.
110
111
        Longitude degrees are in the range 000 to 180. Longitude minutes are
112
        expressed as whole minutes and hundredths of a minute, separated by a
113
        decimal point.
114
115
        For example:
116
117
            07201.75W is 72 degrees 1 minute 45 seconds west.
118
119
        In generic format examples, the longitude is shown as the 9-character
120
        string dddmm.hhW (i.e. degrees, minutes and hundredths of a minute
121
        west).
122
        """
123
        test_lng = -122.38833
124
        aprs_lng = apex.aprs.util.dec2dm_lng(test_lng)
125
        self.logger.debug('aprs_lng=%s', aprs_lng)
126
127
        lng_deg = int(aprs_lng.split('.')[0][:2])
128
        # lng_hsec = aprs_lng.split('.')[1]
129
130
        self.assertTrue(len(aprs_lng) == 9)
131
        self.assertTrue(lng_deg >= 000)
132
        self.assertTrue(lng_deg <= 180)
133
        self.assertTrue(aprs_lng.endswith('W'))
134
135
    def test_longitude_east(self):
136
        """Test Decimal to APRS Longitude conversion.
137
138
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
@@ 42-71 (lines=30) @@
39
40
    def test_latitude_north(self):
41
        """Test Decimal to APRS Latitude conversion.
42
43
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
44
        --
45
        Latitude is expressed as a fixed 8-character field, in degrees and
46
        decimal minutes (to two decimal places), followed by the letter N for
47
        north or S for south. Latitude degrees are in the range 00 to 90.
48
        Latitude minutes are expressed as whole minutes and hundredths of a
49
        minute, separated by a decimal point.
50
51
        For example:
52
53
            4903.50N is 49 degrees 3 minutes 30 seconds north.
54
55
        In generic format examples, the latitude is shown as the 8-character
56
        string ddmm.hhN (i.e. degrees, minutes and hundredths of a minute
57
        north).
58
        """
59
        test_lat = 37.7418096
60
        aprs_lat = apex.aprs.util.dec2dm_lat(test_lat)
61
        self.logger.debug('aprs_lat=%s', aprs_lat)
62
63
        lat_deg = int(aprs_lat.split('.')[0][:1])
64
        # lat_hsec = aprs_lat.split('.')[1]
65
66
        self.assertTrue(len(aprs_lat) == 8)
67
        self.assertTrue(lat_deg >= 00)
68
        self.assertTrue(lat_deg <= 90)
69
        self.assertTrue(aprs_lat.endswith('N'))
70
71
    def test_latitude_south(self):
72
        """Test Decimal to APRS Latitude conversion.
73
74
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf