def test_hmget(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h.hmget(['c', 'b']), ['cc', 'bb'])
def test_hvals(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertItemsEqual(h.hvals(), ['aa', 'bb', 'cc'])
def test_hmset(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h._data, {'a': 'aa', 'b': 'bb', 'c': 'cc'}) h.hmset({'a': 'aaa', 'b': 'bbb', 'z': 'zz'}) self.assertEqual(h._data, {'a': 'aaa', 'b': 'bbb', 'c': 'cc', 'z': 'zz'})
def test_hlen(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h.hlen(), 3)
def test_hgetall(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h.hgetall(), {'a': 'aa', 'b': 'bb', 'c': 'cc'})
def test_hexists(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertTrue(h.hexists('a')) self.assertFalse(h.hexists('z'))
def test_hdel(self): h = Hash() h.hmset({'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h._data, {'a': 'aa', 'b': 'bb', 'c': 'cc'}) self.assertEqual(h.hdel('a', 'b'), 2) self.assertEqual(h._data, {'c': 'cc'})