Beispiel #1
0
    def test_shard_id(self):
        assert BlueShard.shard_id("111101123456") == "0"
        assert BlueShard.shard_id("0000f0123456") == "f"
        assert BlueShard.shard_id("") is None
        assert BlueShard.shard_id(None) is None

        mac = encode_mac("0000f0123456")
        assert BlueShard.shard_id(mac) == "f"
Beispiel #2
0
    def test_shard_id(self):
        assert BlueShard.shard_id('111101123456') == '0'
        assert BlueShard.shard_id('0000f0123456') == 'f'
        assert BlueShard.shard_id('') is None
        assert BlueShard.shard_id(None) is None

        mac = encode_mac('0000f0123456')
        assert BlueShard.shard_id(mac) == 'f'
Beispiel #3
0
    def test_shard_model(self):
        self.assertIs(BlueShard.shard_model('111101123456'), BlueShard0)
        self.assertIs(BlueShard.shard_model('0000f0123456'), BlueShardF)
        self.assertIs(BlueShard.shard_model(''), None)
        self.assertIs(BlueShard.shard_model(None), None)

        mac = encode_mac('0000f0123456')
        self.assertEqual(BlueShard.shard_model(mac), BlueShardF)
Beispiel #4
0
    def test_shard_model(self):
        assert BlueShard.shard_model("111101123456") is BlueShard0
        assert BlueShard.shard_model("0000f0123456") is BlueShardF
        assert BlueShard.shard_model("") is None
        assert BlueShard.shard_model(None) is None

        mac = encode_mac("0000f0123456")
        assert BlueShard.shard_model(mac) is BlueShardF
Beispiel #5
0
    def test_shard_id(self):
        self.assertEqual(BlueShard.shard_id('111101123456'), '0')
        self.assertEqual(BlueShard.shard_id('0000f0123456'), 'f')
        self.assertEqual(BlueShard.shard_id(''), None)
        self.assertEqual(BlueShard.shard_id(None), None)

        mac = encode_mac('0000f0123456')
        self.assertEqual(BlueShard.shard_id(mac), 'f')
Beispiel #6
0
    def test_shard_model(self):
        assert BlueShard.shard_model('111101123456') is BlueShard0
        assert BlueShard.shard_model('0000f0123456') is BlueShardF
        assert BlueShard.shard_model('') is None
        assert BlueShard.shard_model(None) is None

        mac = encode_mac('0000f0123456')
        assert BlueShard.shard_model(mac) is BlueShardF
Beispiel #7
0
    def test_shard_model(self):
        assert BlueShard.shard_model('111101123456') is BlueShard0
        assert BlueShard.shard_model('0000f0123456') is BlueShardF
        assert BlueShard.shard_model('') is None
        assert BlueShard.shard_model(None) is None

        mac = encode_mac('0000f0123456')
        assert BlueShard.shard_model(mac) is BlueShardF
Beispiel #8
0
    def test_shard_id(self):
        assert BlueShard.shard_id('111101123456') == '0'
        assert BlueShard.shard_id('0000f0123456') == 'f'
        assert BlueShard.shard_id('') is None
        assert BlueShard.shard_id(None) is None

        mac = encode_mac('0000f0123456')
        assert BlueShard.shard_id(mac) == 'f'
Beispiel #9
0
    def test_fields(self):
        now = util.utcnow()
        today = now.date()
        self.session.add(BlueShard.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, weight=1.5, last_seen=today,
            block_first=today, block_last=today, block_count=1,
            _raise_invalid=True,
        ))
        self.session.flush()

        blue = self.session.query(BlueShard0).first()
        self.assertEqual(blue.mac, '111101123456')
        self.assertEqual(blue.created, now)
        self.assertEqual(blue.modified, now)
        self.assertEqual(blue.lat, GB_LAT)
        self.assertEqual(blue.max_lat, GB_LAT)
        self.assertEqual(blue.min_lat, GB_LAT)
        self.assertEqual(blue.lon, GB_LON)
        self.assertEqual(blue.max_lon, GB_LON)
        self.assertEqual(blue.min_lon, GB_LON)
        self.assertEqual(blue.radius, 200)
        self.assertEqual(blue.region, 'GB')
        self.assertEqual(blue.samples, 10)
        self.assertEqual(blue.source, StationSource.gnss)
        self.assertEqual(blue.weight, 1.5)
        self.assertEqual(blue.last_seen, today)
        self.assertEqual(blue.block_first, today)
        self.assertEqual(blue.block_last, today)
        self.assertEqual(blue.block_count, 1)
Beispiel #10
0
 def test_score(self):
     now = util.utcnow()
     blue = BlueShard.create(
         mac='111101123456', created=now, modified=now,
         radius=10, samples=2,
     )
     self.assertAlmostEqual(blue.score(now), 0.1, 2)
Beispiel #11
0
    def test_fields(self, session):
        now = util.utcnow()
        today = now.date()
        session.add(BlueShard.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()

        blue = session.query(BlueShard0).first()
        assert blue.mac == '111101123456'
        assert blue.created == now
        assert blue.modified == now
        assert blue.lat == GB_LAT
        assert blue.max_lat == GB_LAT
        assert blue.min_lat == GB_LAT
        assert blue.lon == GB_LON
        assert blue.max_lon == GB_LON
        assert blue.min_lon == GB_LON
        assert blue.radius == 200
        assert blue.region == 'GB'
        assert blue.samples == 10
        assert blue.source == ReportSource.gnss
        assert blue.weight == 1.5
        assert blue.last_seen == today
        assert blue.block_first == today
        assert blue.block_last == today
        assert blue.block_count == 1
Beispiel #12
0
 def test_score(self):
     now = util.utcnow()
     blue = BlueShard.create(
         mac='111101123456', created=now, modified=now,
         radius=10, samples=2,
     )
     assert round(blue.score(now), 2) == 0.1
Beispiel #13
0
    def test_fields(self, session):
        now = util.utcnow()
        today = now.date()
        session.add(
            BlueShard.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()

        blue = session.query(BlueShard0).first()
        assert blue.mac == "111101123456"
        assert blue.created == now
        assert blue.modified == now
        assert blue.lat == GB_LAT
        assert blue.max_lat == GB_LAT
        assert blue.min_lat == GB_LAT
        assert blue.lon == GB_LON
        assert blue.max_lon == GB_LON
        assert blue.min_lon == GB_LON
        assert blue.radius == 200
        assert blue.region == "GB"
        assert blue.samples == 10
        assert blue.source == ReportSource.gnss
        assert blue.weight == 1.5
        assert blue.last_seen == today
        assert blue.block_first == today
        assert blue.block_last == today
        assert blue.block_count == 1
 def shard_model(self):
     return BlueShard.shard_model(self.mac)
 def shard_id(self):
     return BlueShard.shard_id(self.mac)
Beispiel #16
0
 def shard_model(self):
     return BlueShard.shard_model(self.mac)
Beispiel #17
0
 def shard_id(self):
     return BlueShard.shard_id(self.mac)