Code Duplication    Length = 30-32 lines in 2 locations

tests/test_util.py 2 locations

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