Ejemplo n.º 1
0
    def test_min(self):
        value = encode_mac('000000000000')
        self.assertEqual(len(value), 6)
        self.assertEqual(value, b'\x00\x00\x00\x00\x00\x00')

        value = encode_mac('000000000000', codec='base64')
        self.assertEqual(value, b'AAAAAAAA')
Ejemplo n.º 2
0
    def test_max(self):
        value = encode_mac('ffffffffffff')
        self.assertEqual(len(value), 6)
        self.assertEqual(value, b'\xff\xff\xff\xff\xff\xff')

        value = encode_mac('ffffffffffff', codec='base64')
        self.assertEqual(value, b'////////')
Ejemplo n.º 3
0
    def test_encode(self):
        value = encode_mac('abcded123456')
        self.assertEqual(len(value), 6)
        self.assertEqual(value, b'\xab\xcd\xed\x124V')

        value = encode_mac('abcded123456', codec='base64')
        self.assertEqual(value, b'q83tEjRW')
Ejemplo n.º 4
0
    def test_shard_model(self):
        self.assertIs(WifiShard.shard_model('111101123456'), WifiShard0)
        self.assertIs(WifiShard.shard_model('0000f0123456'), WifiShardF)
        self.assertIs(WifiShard.shard_model(''), None)
        self.assertIs(WifiShard.shard_model(None), None)

        mac = encode_mac('0000f0123456')
        self.assertEqual(WifiShard.shard_model(mac), WifiShardF)
Ejemplo n.º 5
0
    def test_shard_id(self):
        self.assertEqual(WifiShard.shard_id('111101123456'), '0')
        self.assertEqual(WifiShard.shard_id('0000f0123456'), 'f')
        self.assertEqual(WifiShard.shard_id(''), None)
        self.assertEqual(WifiShard.shard_id(None), None)

        mac = encode_mac('0000f0123456')
        self.assertEqual(WifiShard.shard_id(mac), 'f')
Ejemplo n.º 6
0
 def _cache_keys_wifi(self, wifi_query):
     keys = []
     for wifi in wifi_query:
         keys.append(self.cache_key_wifi + encode_mac(wifi.mac))
     return keys
Ejemplo n.º 7
0
 def _cache_keys_wifi(self, wifi_query):
     keys = []
     for wifi in wifi_query:
         keys.append(self.cache_key_wifi + encode_mac(wifi.mac))
     return keys