Esempio n. 1
0
 def _setup_plus_cache(self):
     from amplify.agent.tanks.plus_cache import PlusCache
     self.plus_cache = PlusCache()
Esempio n. 2
0
    def teardown_method(self, method):
        self.plus_cache = None
        context.plus_cache = PlusCache()

        super(PlusCacheTestCase, self).teardown_method(method)
Esempio n. 3
0
    def setup_method(self, method):
        super(PlusCacheTestCase, self).setup_method(method)

        context.plus_cache = None
        self.plus_cache = PlusCache()
Esempio n. 4
0
class PlusCacheTestCase(BaseTestCase):
    def setup_method(self, method):
        super(PlusCacheTestCase, self).setup_method(method)

        context.plus_cache = None
        self.plus_cache = PlusCache()

    def teardown_method(self, method):
        self.plus_cache = None
        context.plus_cache = PlusCache()

        super(PlusCacheTestCase, self).teardown_method(method)

    def test_init(self):
        assert_that(self.plus_cache, is_not(equal_to(None)))

    def test_get(self):
        assert_that(self.plus_cache['new'], equal_to(deque(maxlen=3)))

    def test_put(self):
        self.plus_cache.put('new', 'data')
        assert_that(self.plus_cache['new'], has_length(1))
        assert_that(self.plus_cache['new'], has_item('data'))

    def test_del(self):
        self.plus_cache.put('new', 'data')
        assert_that(self.plus_cache['new'], has_length(1))

        del self.plus_cache['new']
        assert_that(self.plus_cache['new'], equal_to(deque(maxlen=3)))

    def test_limit(self):
        for x in xrange(10):
            self.plus_cache.put('new', x)

        assert_that(self.plus_cache['new'], has_length(3))
        assert_that(self.plus_cache['new'],
                    equal_to(deque([x for x in xrange(10)][-3:])))

    def test_get_last_none(self):
        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to((None, None)))

    def test_get_last_empty(self):
        new_deque = self.plus_cache['new']
        assert_that(new_deque, equal_to(deque(maxlen=3)))

        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to((None, None)))

    def test_get_last(self):
        self.plus_cache.put('new', 'data')
        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to('data'))
    def setup_method(self, method):
        super(PlusCacheTestCase, self).setup_method(method)

        context.plus_cache = None
        self.plus_cache = PlusCache()
class PlusCacheTestCase(BaseTestCase):
    def setup_method(self, method):
        super(PlusCacheTestCase, self).setup_method(method)

        context.plus_cache = None
        self.plus_cache = PlusCache()

    def teardown_method(self, method):
        self.plus_cache = None
        context.plus_cache = PlusCache()
        super(PlusCacheTestCase, self).teardown_method(method)

    def test_init(self):
        assert_that(self.plus_cache, is_not(equal_to(None)))

    def test_get(self):
        assert_that(self.plus_cache['new'], equal_to(deque(maxlen=3)))

    def test_put(self):
        self.plus_cache.put('new', 'data')
        assert_that(self.plus_cache['new'], has_length(1))
        assert_that(self.plus_cache['new'], has_item('data'))

    def test_del(self):
        self.plus_cache.put('new', 'data')
        assert_that(self.plus_cache['new'], has_length(1))

        del self.plus_cache['new']
        assert_that(self.plus_cache['new'], equal_to(deque(maxlen=3)))

    def test_limit(self):
        for x in xrange(10):
            self.plus_cache.put('new', x)

        assert_that(self.plus_cache['new'], has_length(3))
        assert_that(self.plus_cache['new'], equal_to(deque([x for x in xrange(10)][-3:])))

    def test_get_last_none(self):
        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to((None, None)))

    def test_get_last_empty(self):
        new_deque = self.plus_cache['new']
        assert_that(new_deque, equal_to(deque(maxlen=3)))

        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to((None, None)))

    def test_get_last(self):
        self.plus_cache.put('new', 'data')
        last = self.plus_cache.get_last('new')
        assert_that(last, equal_to('data'))