def test_mul(self): a = 420 b = hot_redis.Int(a) i = 9000 self.assertEquals(a * i, hot_redis.Int(a) * i) b *= i self.assertEquals(a * i, b)
def test_rshift(self): a = 9000 b = 4 self.assertEquals(a >> b, hot_redis.Int(a) >> hot_redis.Int(b)) self.assertEquals(a >> b, hot_redis.Int(a) >> b) c = hot_redis.Int(a) d = hot_redis.Int(b) d >>= c c >>= b self.assertEquals(a >> b, c) self.assertEquals(b >> a, d)
def test_lshift(self): a = 4 b = 20 self.assertEquals(a << b, hot_redis.Int(a) << hot_redis.Int(b)) self.assertEquals(a << b, hot_redis.Int(a) << b) c = hot_redis.Int(a) d = hot_redis.Int(b) d <<= c c <<= b self.assertEquals(a << b, c) self.assertEquals(b << a, d)
def test_xor(self): a = 420 b = 9000 self.assertEquals(a ^ b, hot_redis.Int(a) ^ hot_redis.Int(b)) self.assertEquals(a ^ b, hot_redis.Int(a) ^ b) c = hot_redis.Int(a) d = hot_redis.Int(b) d ^= c c ^= b self.assertEquals(a ^ b, c) self.assertEquals(b ^ a, d)
def test_or(self): a = 420 b = 9000 self.assertEquals(a | b, hot_redis.Int(a) | hot_redis.Int(b)) self.assertEquals(a | b, hot_redis.Int(a) | b) c = hot_redis.Int(a) d = hot_redis.Int(b) d |= c c |= b self.assertEquals(a | b, c) self.assertEquals(b | a, d)
def test_add(self): a = 420 b = 9000 self.assertEquals(a & b, hot_redis.Int(a) & hot_redis.Int(b)) self.assertEquals(a & b, hot_redis.Int(a) & b) c = hot_redis.Int(a) d = hot_redis.Int(b) d &= c c &= b self.assertEquals(a & b, c) self.assertEquals(b & a, d)
def test_pow(self): a = 4 b = 20 self.assertEquals(a**b, hot_redis.Int(a)**hot_redis.Int(b)) self.assertEquals(a**b, hot_redis.Int(a)**b) c = hot_redis.Int(a) d = hot_redis.Int(b) d **= c c **= b self.assertEquals(a**b, c) self.assertEquals(b**a, d)
def test_mod(self): a = 420 b = 9000 self.assertEquals(a % b, hot_redis.Int(a) % hot_redis.Int(b)) self.assertEquals(a % b, hot_redis.Int(a) % b) c = hot_redis.Int(a) d = hot_redis.Int(b) d %= c c %= b self.assertEquals(a % b, c) self.assertEquals(b % a, d)
def test_div(self): a = 420 b = 9000 self.assertEquals(a / b, hot_redis.Int(a) / hot_redis.Int(b)) self.assertEquals(a / b, hot_redis.Int(a) / b) c = hot_redis.Int(a) d = hot_redis.Int(b) d /= c c /= b self.assertEquals(a / b, c) self.assertEquals(b / a, d)
def test_sub(self): a = 420 b = 9000 self.assertEquals(a - b, hot_redis.Int(a) - hot_redis.Int(b)) self.assertEquals(a - b, hot_redis.Int(a) - b) c = hot_redis.Int(a) d = hot_redis.Int(b) d -= c c -= b self.assertEquals(a - b, c) self.assertEquals(b - a, d)
def test_add(self): a = 420 b = 9000 self.assertEquals(a + b, hot_redis.Int(a) + hot_redis.Int(b)) self.assertEquals(a + b, hot_redis.Int(a) + b) c = hot_redis.Int(a) d = hot_redis.Int(b) d += c c += b self.assertEquals(a + b, c) self.assertEquals(b + a, d)
def test_set(self): a = 420 b = hot_redis.Int() b.value = a self.assertEqual(b, a) b.value = 0 self.assertEqual(b, 0)
def __init__(self, var, val): if type(val) == dict: # print('dict') instance = hot_redis.Dict(val, key=var) elif type(val) == list: # print('list') instance = hot_redis.List(val, key=var) elif type(val) == set: # print('set') instance = hot_redis.Set(val, key=var) elif type(val) == str: # print('str') instance = hot_redis.String(val, key=var) elif type(val) == int: # print('int') instance = hot_redis.Int(val, key=var) elif type(val) == None: # Not handled # print('None Not handled') return None elif callable(val): # print('function') return None else: # print("else, None:", type(val)) return None # instance = hot_redis(instance) # print("debug: ", var, val) self.instance = instance
def __init__(self, doc=''): self.user_key = doc + USERS self.users = hot_redis.Dict(key=self.user_key, client=client) self.id = hot_redis.Int(key=self.user_key + "ID", client=client) self.changes = hot_redis.Dict(key=self.user_key + "changes", client=client) self.user_changes = hot_redis.Dict(key=self.user_key + "userChangesMap", client=client)
def test_empty(self): self.assertEquals(hot_redis.Int(), .0)
def test_value(self): a = 420 self.assertEquals(hot_redis.Int(a), a)