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
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
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": []}
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(self): with pytest.raises(colander.Invalid): SUBMIT_V0_SCHEMA.deserialize({})
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': []}