def test_basic(self):
        plus_obj = PlusObject(local_name='test_obj', parent_local_id='nginx123', root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        status_collector = PlusStatusCollector(object=plus_obj)
        assert_that(status_collector.last_collect, equal_to(None))
        data = status_collector.gather_data()

        assert_that(data, equal_to([]))
    def test_basic(self):
        plus_obj = PlusObject(local_name='test_obj',
                              parent_local_id='nginx123',
                              root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        status_collector = PlusStatusCollector(object=plus_obj)
        assert_that(status_collector.last_collect, equal_to(None))
        data = status_collector.gather_data()

        assert_that(data, equal_to([]))
    def test_dummy_data(self):
        plus_obj = PlusObject(local_name='test_obj', parent_local_id='nginx123', root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        # Insert some dummy data
        context.plus_cache.put('test_status', ({'pluss': {'test_obj': {}}}, 0))

        status_collector = PlusStatusCollector(object=plus_obj)
        assert_that(status_collector.last_collect, equal_to(None))
        data = status_collector.gather_data()

        assert_that(data, equal_to([({}, 0)]))
        assert_that(status_collector.last_collect, equal_to(0))
    def test_dummy_data(self):
        plus_obj = PlusObject(local_name='test_obj',
                              parent_local_id='nginx123',
                              root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        # Insert some dummy data
        context.plus_cache.put('test_status', ({'pluss': {'test_obj': {}}}, 0))

        status_collector = PlusStatusCollector(object=plus_obj)
        assert_that(status_collector.last_collect, equal_to(None))
        data = status_collector.gather_data()

        assert_that(data, equal_to([({}, 0)]))
        assert_that(status_collector.last_collect, equal_to(0))
    def test_old_dummy_data(self):
        plus_obj = PlusObject(local_name='test_obj', parent_local_id='nginx123', root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        # Insert some dummy data
        context.plus_cache.put('test_status', ({'pluss': {'test_obj': {}}}, 0))
        context.plus_cache.put('test_status', ({'pluss': {'test_obj': {'proper': 'data'}}}, 2))

        status_collector = PlusStatusCollector(object=plus_obj)
        status_collector.last_collect = 1  # Hard set timestamp
        data = status_collector.gather_data()

        assert_that(data, has_length(1))
        assert_that(data, equal_to([({'proper': 'data'}, 2)]))
        assert_that(status_collector.last_collect, equal_to(2))
    def test_old_dummy_data(self):
        plus_obj = PlusObject(local_name='test_obj',
                              parent_local_id='nginx123',
                              root_uuid='root123')
        # Do a quick override of plus_status_internal_url_cache
        plus_obj.plus_status_internal_url_cache = 'test_status'

        # Insert some dummy data
        context.plus_cache.put('test_status', ({'pluss': {'test_obj': {}}}, 0))
        context.plus_cache.put('test_status', ({
            'pluss': {
                'test_obj': {
                    'proper': 'data'
                }
            }
        }, 2))

        status_collector = PlusStatusCollector(object=plus_obj)
        status_collector.last_collect = 1  # Hard set timestamp
        data = status_collector.gather_data()

        assert_that(data, has_length(1))
        assert_that(data, equal_to([({'proper': 'data'}, 2)]))
        assert_that(status_collector.last_collect, equal_to(2))