Code Duplication    Length = 30-32 lines in 2 locations

tests/test_util.py 2 locations

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