Code Duplication    Length = 30-32 lines in 4 locations

tests/test_util.py 4 locations

@@ 137-168 (lines=32) @@
134
        self.assertTrue(lng_deg <= 180)
135
        self.assertTrue(aprs_lng.endswith('W'))
136
137
    def test_longitude_east(self):
138
        """Test Decimal to APRS Longitude conversion.
139
140
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
141
        --
142
        Longitude is expressed as a fixed 9-character field, in degrees and
143
        decimal minutes (to two decimal places), followed by the letter E for
144
        east or W for west.
145
146
        Longitude degrees are in the range 000 to 180. Longitude minutes are
147
        expressed as whole minutes and hundredths of a minute, separated by a
148
        decimal point.
149
150
        For example:
151
152
            07201.75W is 72 degrees 1 minute 45 seconds west.
153
154
        In generic format examples, the longitude is shown as the 9-character
155
        string dddmm.hhW (i.e. degrees, minutes and hundredths of a minute
156
        west).
157
        """
158
        test_lng = 122.38833
159
        aprs_lng = apex.aprs.util.dec2dm_lng(test_lng)
160
        self.logger.debug('aprs_lng=%s', aprs_lng)
161
162
        lng_deg = int(aprs_lng.split('.')[0][:2])
163
        # lng_hsec = aprs_lng.split('.')[1]
164
165
        self.assertTrue(len(aprs_lng) == 9)
166
        self.assertTrue(lng_deg >= 000)
167
        self.assertTrue(lng_deg <= 180)
168
        self.assertTrue(aprs_lng.endswith('E'))
169
170
    def test_valid_callsign_valid(self):
171
        """
@@ 104-135 (lines=32) @@
101
        self.assertTrue(lat_deg <= 90)
102
        self.assertTrue(aprs_lat.endswith('S'))
103
104
    def test_longitude_west(self):
105
        """Test Decimal to APRS Longitude conversion.
106
107
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
108
        --
109
        Longitude is expressed as a fixed 9-character field, in degrees and
110
        decimal minutes (to two decimal places), followed by the letter E for
111
        east or W for west.
112
113
        Longitude degrees are in the range 000 to 180. Longitude minutes are
114
        expressed as whole minutes and hundredths of a minute, separated by a
115
        decimal point.
116
117
        For example:
118
119
            07201.75W is 72 degrees 1 minute 45 seconds west.
120
121
        In generic format examples, the longitude is shown as the 9-character
122
        string dddmm.hhW (i.e. degrees, minutes and hundredths of a minute
123
        west).
124
        """
125
        test_lng = -122.38833
126
        aprs_lng = apex.aprs.util.dec2dm_lng(test_lng)
127
        self.logger.debug('aprs_lng=%s', aprs_lng)
128
129
        lng_deg = int(aprs_lng.split('.')[0][:2])
130
        # lng_hsec = aprs_lng.split('.')[1]
131
132
        self.assertTrue(len(aprs_lng) == 9)
133
        self.assertTrue(lng_deg >= 000)
134
        self.assertTrue(lng_deg <= 180)
135
        self.assertTrue(aprs_lng.endswith('W'))
136
137
    def test_longitude_east(self):
138
        """Test Decimal to APRS Longitude conversion.
@@ 73-102 (lines=30) @@
70
        self.assertTrue(lat_deg <= 90)
71
        self.assertTrue(aprs_lat.endswith('N'))
72
73
    def test_latitude_south(self):
74
        """Test Decimal to APRS Latitude conversion.
75
76
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
77
        --
78
        Latitude is expressed as a fixed 8-character field, in degrees and
79
        decimal minutes (to two decimal places), followed by the letter N for
80
        north or S for south. Latitude degrees are in the range 00 to 90.
81
        Latitude minutes are expressed as whole minutes and hundredths of a
82
        minute, separated by a decimal point.
83
84
        For example:
85
86
            4903.50N is 49 degrees 3 minutes 30 seconds north.
87
88
        In generic format examples, the latitude is shown as the 8-character
89
        string ddmm.hhN (i.e. degrees, minutes and hundredths of a minute
90
        north).
91
        """
92
        test_lat = -37.7418096
93
        aprs_lat = apex.aprs.util.dec2dm_lat(test_lat)
94
        self.logger.debug('aprs_lat=%s', aprs_lat)
95
96
        lat_deg = int(aprs_lat.split('.')[0][:1])
97
        # lat_hsec = aprs_lat.split('.')[1]
98
99
        self.assertTrue(len(aprs_lat) == 8)
100
        self.assertTrue(lat_deg >= 00)
101
        self.assertTrue(lat_deg <= 90)
102
        self.assertTrue(aprs_lat.endswith('S'))
103
104
    def test_longitude_west(self):
105
        """Test Decimal to APRS Longitude conversion.
@@ 42-71 (lines=30) @@
39
    logger.addHandler(console_handler)
40
    logger.propagate = False
41
42
    def test_latitude_north(self):
43
        """Test Decimal to APRS Latitude conversion.
44
45
        Spec per ftp://ftp.tapr.org/aprssig/aprsspec/spec/aprs101/APRS101.pdf
46
        --
47
        Latitude is expressed as a fixed 8-character field, in degrees and
48
        decimal minutes (to two decimal places), followed by the letter N for
49
        north or S for south. Latitude degrees are in the range 00 to 90.
50
        Latitude minutes are expressed as whole minutes and hundredths of a
51
        minute, separated by a decimal point.
52
53
        For example:
54
55
            4903.50N is 49 degrees 3 minutes 30 seconds north.
56
57
        In generic format examples, the latitude is shown as the 8-character
58
        string ddmm.hhN (i.e. degrees, minutes and hundredths of a minute
59
        north).
60
        """
61
        test_lat = 37.7418096
62
        aprs_lat = apex.aprs.util.dec2dm_lat(test_lat)
63
        self.logger.debug('aprs_lat=%s', aprs_lat)
64
65
        lat_deg = int(aprs_lat.split('.')[0][:1])
66
        # lat_hsec = aprs_lat.split('.')[1]
67
68
        self.assertTrue(len(aprs_lat) == 8)
69
        self.assertTrue(lat_deg >= 00)
70
        self.assertTrue(lat_deg <= 90)
71
        self.assertTrue(aprs_lat.endswith('N'))
72
73
    def test_latitude_south(self):
74
        """Test Decimal to APRS Latitude conversion.