Exemple #1
0
    def test_timestamp(self):
        wifi = WifiShardFactory.build()

        data = SUBMIT_V0_SCHEMA.deserialize(
            {"items": [{"time": "2016-04-07T03:33:20", "wifi": [{"key": wifi.mac}]}]}
        )
        assert data["items"][0]["timestamp"] == 146 * 10 ** 10

        data = SUBMIT_V0_SCHEMA.deserialize(
            {"items": [{"time": "1710-02-28", "wifi": [{"key": wifi.mac}]}]}
        )
        # 1710 was discarded and replaced by 'now'
        assert data["items"][0]["timestamp"] > 10 ** 12
Exemple #2
0
    def test_timestamp(self):
        wifi = WifiShardFactory.build()

        data = SUBMIT_V0_SCHEMA.deserialize(
            {'items': [{'time': '2016-04-07T03:33:20',
                        'wifi': [{'key': wifi.mac}]}]})
        assert data['items'][0]['timestamp'] == 146 * 10 ** 10

        data = SUBMIT_V0_SCHEMA.deserialize(
            {'items': [{'time': '1710-02-28',
                        'wifi': [{'key': wifi.mac}]}]})
        # 1710 was discarded and replaced by 'now'
        assert data['items'][0]['timestamp'] > 10 ** 12
    def test_timestamp(self):
        wifi = WifiShardFactory.build()

        data = SUBMIT_V0_SCHEMA.deserialize(
            {'items': [{'time': '2016-04-07T03:33:20',
                        'wifi': [{'key': wifi.mac}]}]})
        assert data['items'][0]['timestamp'] == 146 * 10 ** 10

        data = SUBMIT_V0_SCHEMA.deserialize(
            {'items': [{'time': '1710-02-28',
                        'wifi': [{'key': wifi.mac}]}]})
        # 1710 was discarded and replaced by 'now'
        assert data['items'][0]['timestamp'] > 10 ** 12
Exemple #4
0
 def test_minimal(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize(
         {'items': [{'lat': wifi.lat, 'lon': wifi.lon,
                     'wifi': [{'key': 'ab'}]}]})
     assert 'items' in data
     assert len(data['items']) == 1
Exemple #5
0
 def test_minimal(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize(
         {"items": [{"lat": wifi.lat, "lon": wifi.lon, "wifi": [{"key": "ab"}]}]}
     )
     assert "items" in data
     assert len(data["items"]) == 1
 def test_minimal(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize(
         {'items': [{'lat': wifi.lat, 'lon': wifi.lon,
                     'wifi': [{'key': 'ab'}]}]})
     assert 'items' in data
     assert len(data['items']) == 1
Exemple #7
0
    def test_cell_radio(self):
        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize({'items': [
            {'lat': cell.lat, 'lon': cell.lon, 'cell': [{
                'radio': 'UMTS', 'mcc': cell.mcc, 'mnc': cell.mnc,
                'lac': cell.lac, 'cid': cell.cid,
            }]}
        ]})
        assert data['items'][0]['cellTowers'][0]['radioType'] == 'wcdma'

        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize({'items': [
            {'lat': cell.lat, 'lon': cell.lon, 'cell': [{
                'radio': 'foo', 'mcc': cell.mcc, 'mnc': cell.mnc,
                'lac': cell.lac, 'cid': cell.cid,
            }]}
        ]})
        assert 'radioType' not in data['items'][0]['cellTowers'][0]
    def test_cell_radio(self):
        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize({'items': [
            {'lat': cell.lat, 'lon': cell.lon, 'cell': [{
                'radio': 'UMTS', 'mcc': cell.mcc, 'mnc': cell.mnc,
                'lac': cell.lac, 'cid': cell.cid,
            }]}
        ]})
        assert data['items'][0]['cellTowers'][0]['radioType'] == 'wcdma'

        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize({'items': [
            {'lat': cell.lat, 'lon': cell.lon, 'cell': [{
                'radio': 'foo', 'mcc': cell.mcc, 'mnc': cell.mnc,
                'lac': cell.lac, 'cid': cell.cid,
            }]}
        ]})
        assert 'radioType' not in data['items'][0]['cellTowers'][0]
 def test_empty_wifi_entry(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize(
         {"items": [{
             "lat": wifi.lat,
             "lon": wifi.lon,
             "wifi": [{}]
         }]})
     assert data == {"items": []}
 def test_empty_blue_entry(self):
     blue = BlueShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize(
         {"items": [{
             "lat": blue.lat,
             "lon": blue.lon,
             "blue": [{}]
         }]})
     assert data == {"items": []}
Exemple #11
0
    def test_cell_radio(self):
        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize(
            {
                "items": [
                    {
                        "lat": cell.lat,
                        "lon": cell.lon,
                        "cell": [
                            {
                                "radio": "UMTS",
                                "mcc": cell.mcc,
                                "mnc": cell.mnc,
                                "lac": cell.lac,
                                "cid": cell.cid,
                            }
                        ],
                    }
                ]
            }
        )
        assert data["items"][0]["cellTowers"][0]["radioType"] == "wcdma"

        cell = CellShardFactory.build()
        data = SUBMIT_V0_SCHEMA.deserialize(
            {
                "items": [
                    {
                        "lat": cell.lat,
                        "lon": cell.lon,
                        "cell": [
                            {
                                "radio": "foo",
                                "mcc": cell.mcc,
                                "mnc": cell.mnc,
                                "lac": cell.lac,
                                "cid": cell.cid,
                            }
                        ],
                    }
                ]
            }
        )
        assert "radioType" not in data["items"][0]["cellTowers"][0]
Exemple #12
0
 def test_empty_wifi_entry(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize({'items': [
         {'lat': wifi.lat, 'lon': wifi.lon, 'wifi': [{}]},
     ]})
     assert data == {'items': []}
Exemple #13
0
 def test_empty(self):
     with pytest.raises(colander.Invalid):
         SUBMIT_V0_SCHEMA.deserialize({})
 def test_empty_wifi_entry(self):
     wifi = WifiShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize({'items': [
         {'lat': wifi.lat, 'lon': wifi.lon, 'wifi': [{}]},
     ]})
     assert data == {'items': []}
Exemple #15
0
 def test_empty_blue_entry(self):
     blue = BlueShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize({'items': [
         {'lat': blue.lat, 'lon': blue.lon, 'blue': [{}]},
     ]})
     assert data == {'items': []}
 def test_empty_blue_entry(self):
     blue = BlueShardFactory.build()
     data = SUBMIT_V0_SCHEMA.deserialize({'items': [
         {'lat': blue.lat, 'lon': blue.lon, 'blue': [{}]},
     ]})
     assert data == {'items': []}
 def test_empty(self):
     with pytest.raises(colander.Invalid):
         SUBMIT_V0_SCHEMA.deserialize({})