class TestMockCouchbaseViews(unittest.TestCase):

    def setUp(self):
        self.mock_db = MockCouchbase()["bucket_name"]
        self.views = {
            'places' : {
                'Europe': {
                    'UK': {
                        'Scotland': 'Edinburgh',
                        'England': 'London'
                    }
                }
            }
        }
        self.mock_db.set_views(self.views)

    def test_can_get_view(self):
        places = self.mock_db.view('places')
        self.assertEqual(places['Europe']['UK']['Scotland'], 'Edinburgh')
 def setUp(self):
     self.mock_db = MockCouchbase()["bucket_name"]
     self.views = {
         'places' : {
             'Europe': {
                 'UK': {
                     'Scotland': 'Edinburgh',
                     'England': 'London'
                 }
             }
         }
     }
     self.mock_db.set_views(self.views)
 def test_item_has_expired(self):
     val = "test"
     fake = MockCouchbase()["bucket_name"]
     fake.set("tester", 1, 0, val)
     fake._get_timestamp = self.expired_time
     self.assertDictEqual(fake.get("tester"), {})
 def test_persistant_get_item(self):
     val = "hello world!"
     fake = MockCouchbase()["bucket_name"]
     fake.set("abc", 0, 0, val)
     fake._get_timestamp = self.expired_time
     self.assertEqual(fake.get("abc"), val)
 def test_can_get_and_set(self):
     val = "hello world!"
     fake = MockCouchbase()["bucket_name"]
     fake.set("abc", 5, 0, val)
     self.assertEqual(fake.get("abc"), val)
     self.assertGreater(fake.expiry["abc"], time.time())