import unittest
import datetime
import hiro
import redis
from sifr.span import Minute, Day
from sifr.storage import MemoryStorage, RedisStorage


class RedisStorageTests(unittest.TestCase):
    def setUp(self):
        self.redis = redis.Redis()
        self.redis.flushall()

    def test_incr_simple_minute(self):
        span = Minute(datetime.datetime.now(), ["minute_span"])
        storage = RedisStorage(self.redis)
        storage.incr(span)
        storage.incr(span)
        self.assertEqual(storage.get(span), 2)

    def test_incr_unique_minute(self):
        red = redis.Redis()
        span = Minute(datetime.datetime.now(), ["minute_span"])
        storage = RedisStorage(red)
        storage.incr_unique(span, "1")
        storage.incr_unique(span, "1")
        storage.incr_unique(span, "2")
        self.assertEqual(storage.get_unique(span), 2)

    def test_tracker_minute(self):
        with hiro.Timeline().freeze() as timeline:
            span = Minute(datetime.datetime.now(), ["minute_span"])
            storage = RedisStorage(self.redis)
            storage.track(span, "1", 3)
            storage.track(span, "1", 3)
            storage.track(span, "2", 3)
            storage.track(span, "3", 3)
            self.assertEqual(storage.enumerate(span), set(["1", "2", "3"]))

@@ -896,63 +896,8 @@
 f):%0A
-        with hiro.Timeline().freeze() as timeline:%0A    
     
@@ -960,28 +960,24 @@
 %22%5D)%0A        
-    
 storage = Re
@@ -999,36 +999,32 @@
 .redis)%0A        
- 
-   
 storage.track(sp
@@ -1035,36 +1035,32 @@
 %221%22, 3)%0A        
-  
-  
 storage.track(sp
@@ -1071,36 +1071,32 @@
 %221%22, 3)%0A        
-   
- 
 storage.track(sp
@@ -1103,28 +1103,24 @@
 an, %222%22, 3)%0A
-    
         stor
@@ -1139,28 +1139,24 @@
 an, %223%22, 3)%0A
-    
         self

Remove hiro timeline context in redis test