Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
 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)
Beispiel #12
0
 def test_set(self):
     a = 420
     b = hot_redis.Int()
     b.value = a
     self.assertEqual(b, a)
     b.value = 0
     self.assertEqual(b, 0)
Beispiel #13
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
Beispiel #14
0
 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)
Beispiel #15
0
 def test_empty(self):
     self.assertEquals(hot_redis.Int(), .0)
Beispiel #16
0
 def test_value(self):
     a = 420
     self.assertEquals(hot_redis.Int(a), a)