Exemplo n.º 1
0
 def test_update(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = {"wagwaan": "hotskull", "nba": "hangtime"}
     c = datatype_redis.Dict(a)
     a.update(b)
     c.update(b)
     self.assertEqual(a, c)
Exemplo n.º 2
0
    def test_del(self):
        a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
        del a["wagwaan"]
        self.assertRaises(KeyError, lambda: a["wagwaan"])

        def del_missing():
            del a["hotskull"]

        self.assertRaises(KeyError, del_missing)
Exemplo n.º 3
0
 def test_get(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertEqual(a["wagwaan"], b["wagwaan"])
     self.assertEqual(a.get("wagwaan"), b.get("wagwaan"))
     self.assertRaises(KeyError, lambda: b["hotskull"])
     self.assertEqual(a.get("hotskull"), b.get("hotskull"))
     self.assertEqual(a.get("hotskull", "don"), b.get("hotskull", "don"))
     self.assertNotEqual(a.get("hotskull", "don"), b.get("hotskull", "x"))
Exemplo n.º 4
0
 def test_setdefault(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     c = "nba"
     d = "hangtime"
     e = b.setdefault(c, d)
     self.assertEqual(e, d)
     self.assertEqual(b[c], d)
     self.assertEqual(a.setdefault(c, d), e)
     e = b.setdefault(c, c)
     self.assertEqual(e, d)
     self.assertEqual(a.setdefault(c, c), e)
Exemplo n.º 5
0
 def test_clear(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     a.clear()
     self.assertEqual(len(a), 0)
Exemplo n.º 6
0
 def test_copy(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     b = a.copy()
     self.assertEqual(type(a), type(b))
     self.assertNotEqual(a.key, b.key)
Exemplo n.º 7
0
 def test_empty(self):
     self.assertEqual(datatype_redis.Dict(), {})
Exemplo n.º 8
0
 def test_contains(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertIn("wagwaan", a)
     self.assertNotIn("hotskull", a)
Exemplo n.º 9
0
 def test_len(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     b = datatype_redis.Dict(a)
     self.assertEqual(len(a), len(b))
Exemplo n.º 10
0
 def test_set(self):
     a = datatype_redis.Dict({"wagwaan": "popcaan", "flute": "don"})
     a["wagwaan"] = "hotskull"
     self.assertEqual(a["wagwaan"], "hotskull")
Exemplo n.º 11
0
 def test_value(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertEqual(datatype_redis.Dict(a), a)
Exemplo n.º 12
0
 def test_items(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertItemsEqual(a.items(), datatype_redis.Dict(a).items())
Exemplo n.º 13
0
 def test_iter(self):
     a = {"wagwaan": "popcaan", "flute": "don"}
     self.assertItemsEqual(iter(a), iter(datatype_redis.Dict(a)))