Esempio n. 1
0
 def test_detect_call_sign(self):
     service = LocastService(self.config, MagicMock())
     self.assertEqual(service._detect_callsign("WLTV1"), ("WLTV", "1"))
     self.assertEqual(service._detect_callsign("KLTV1"), ("KLTV", "1"))
     self.assertEqual(service._detect_callsign("KLTVAA1"), ("KLTV", "1"))
     self.assertEqual(service._detect_callsign("KLTV"), ("KLTV", ''))
     self.assertEqual(service._detect_callsign("FLTV1"), None)
Esempio n. 2
0
    def test_internal_get_stations_facility_lookup(self):
        stations = [{
            "callSign": "CBS",
            "name": "WLTV1"
        }, {
            "callSign": "WLTV2",
            "name": "NPR"
        }]

        service = LocastService(self.config, MagicMock())
        service.dma = "123"
        service.city = "Chicago"
        service.timezone = "America/Chicago"
        service._get_locast_stations = get_locast_stations = MagicMock()
        get_locast_stations.return_value = stations
        service._detect_callsign = MagicMock()
        service._detect_callsign.side_effect = [("WLTV", 1), None, ("WLTV", 2)]
        service._fcc_facilities = MagicMock()
        service._fcc_facilities.by_dma_and_call_sign.side_effect = [{
            "channel":
            "2",
            "analog":
            False
        }, {
            "channel":
            "1",
            "analog":
            True
        }]

        result = service._get_stations()

        expected = [{
            "callSign": "CBS",
            "name": "WLTV1",
            "channel": "2.1",
            "city": "Chicago",
            "timezone": "America/Chicago"
        }, {
            'callSign': 'WLTV2',
            'name': 'NPR',
            'city': 'Chicago',
            'channel': '1',
            "timezone": "America/Chicago"
        }]
        get_locast_stations.assert_called()
        service._fcc_facilities.by_dma_and_call_sign.assert_called_with(
            "123", "WLTV")
        self.assertEqual(result, expected)
Esempio n. 3
0
    def test_internal_get_stations_no_call_sign(self):
        stations = [{
            "callSign": "CBS",
            "name": "WLTV1"
        }, {
            "callSign": "WLTV2",
            "name": "NPR"
        }]

        service = LocastService(self.config, MagicMock())
        service.dma = "123"
        service.city = "Chicago"
        service.timezone = "America/Chicago"
        service._get_locast_stations = get_locast_stations = MagicMock()
        get_locast_stations.return_value = stations
        service._detect_callsign = MagicMock()
        service._detect_callsign.return_value = None

        result = service._get_stations()

        expected = [{
            "callSign": "CBS",
            "name": "WLTV1",
            "channel": "1000",
            "city": "Chicago",
            "timezone": "America/Chicago"
        }, {
            'callSign': 'WLTV2',
            'name': 'NPR',
            'city': 'Chicago',
            'channel': '1001',
            'timezone': 'America/Chicago'
        }]
        get_locast_stations.assert_called()

        self.assertEqual(result, expected)