def test_fields(self): now = util.utcnow() today = now.date() self.session.add(WifiShard.create( mac='111101123456', created=now, modified=now, lat=GB_LAT, max_lat=GB_LAT, min_lat=GB_LAT, lon=GB_LON, max_lon=GB_LON, min_lon=GB_LON, radius=200, region='GB', samples=10, source=StationSource.gnss, block_first=today, block_last=today, block_count=1, _raise_invalid=True, )) self.session.flush() wifi = self.session.query(WifiShard0).first() self.assertEqual(wifi.mac, '111101123456') self.assertEqual(wifi.created, now) self.assertEqual(wifi.modified, now) self.assertEqual(wifi.lat, GB_LAT) self.assertEqual(wifi.max_lat, GB_LAT) self.assertEqual(wifi.min_lat, GB_LAT) self.assertEqual(wifi.lon, GB_LON) self.assertEqual(wifi.max_lon, GB_LON) self.assertEqual(wifi.min_lon, GB_LON) self.assertEqual(wifi.radius, 200) self.assertEqual(wifi.region, 'GB') self.assertEqual(wifi.samples, 10) self.assertEqual(wifi.source, StationSource.gnss) self.assertEqual(wifi.block_first, today) self.assertEqual(wifi.block_last, today) self.assertEqual(wifi.block_count, 1)
def test_score(self): now = util.utcnow() wifi = WifiShard.create( mac='111101123456', created=now, modified=now, radius=10, samples=2, ) self.assertAlmostEqual(wifi.score(now), 0.1, 2)
def test_fields(self, session): now = util.utcnow() today = now.date() session.add(WifiShard.create( mac='111101123456', created=now, modified=now, lat=GB_LAT, max_lat=GB_LAT, min_lat=GB_LAT, lon=GB_LON, max_lon=GB_LON, min_lon=GB_LON, radius=200, region='GB', samples=10, source=ReportSource.gnss, weight=1.5, last_seen=today, block_first=today, block_last=today, block_count=1, _raise_invalid=True, )) session.flush() wifi = session.query(WifiShard0).first() assert wifi.mac == '111101123456' assert wifi.created == now assert wifi.modified == now assert wifi.lat == GB_LAT assert wifi.max_lat == GB_LAT assert wifi.min_lat == GB_LAT assert wifi.lon == GB_LON assert wifi.max_lon == GB_LON assert wifi.min_lon == GB_LON assert wifi.radius == 200 assert wifi.region == 'GB' assert wifi.samples == 10 assert wifi.source == ReportSource.gnss assert wifi.weight == 1.5 assert wifi.last_seen == today assert wifi.block_first == today assert wifi.block_last == today assert wifi.block_count == 1
def test_score(self): now = util.utcnow() wifi = WifiShard.create( mac='111101123456', created=now, modified=now, radius=10, samples=2, ) assert round(wifi.score(now), 2) == 0.1
def test_fields(self, session): now = util.utcnow() today = now.date() session.add( WifiShard.create( mac='111101123456', created=now, modified=now, lat=GB_LAT, max_lat=GB_LAT, min_lat=GB_LAT, lon=GB_LON, max_lon=GB_LON, min_lon=GB_LON, radius=200, region='GB', samples=10, source=ReportSource.gnss, weight=1.5, last_seen=today, block_first=today, block_last=today, block_count=1, _raise_invalid=True, )) session.flush() wifi = session.query(WifiShard0).first() assert wifi.mac == '111101123456' assert wifi.created == now assert wifi.modified == now assert wifi.lat == GB_LAT assert wifi.max_lat == GB_LAT assert wifi.min_lat == GB_LAT assert wifi.lon == GB_LON assert wifi.max_lon == GB_LON assert wifi.min_lon == GB_LON assert wifi.radius == 200 assert wifi.region == 'GB' assert wifi.samples == 10 assert wifi.source == ReportSource.gnss assert wifi.weight == 1.5 assert wifi.last_seen == today assert wifi.block_first == today assert wifi.block_last == today assert wifi.block_count == 1