示例#1
0
    def test_with_ip(self):
        service = LocastService(self.config, Geo())
        service._set_attrs_from_geo = set_attrs = MagicMock()

        service._find_location()

        set_attrs.assert_called_with(IP_URL)
示例#2
0
    def test_with_zipcode(self):
        service = LocastService(self.config, Geo("90210"))
        service._set_attrs_from_geo = set_attrs = MagicMock()

        service._find_location()

        url = f"{DMA_URL}/zip/90210"
        set_attrs.assert_called_with(url)
示例#3
0
    def test_with_coords(self):
        service = LocastService(self.config,
                                Geo(None, {
                                    "longitude": 1.0,
                                    "latitude": 2.0
                                }))
        service._set_attrs_from_geo = set_attrs = MagicMock()

        service._find_location()

        url = f"{DMA_URL}/2.0/1.0"
        set_attrs.assert_called_with(url)