def populate(self): self.serviceName = "StorageService" self.dbType = 0 self.mediaType = 1 self.dataLink = "prod.x-in-y.com" # Default link for now self.bucketName = "ONR" self.storage = MongoStorageService(self.serviceName, None) self.storage.addBucket(self.bucketName) # Populate some storage values bucket = self.storage.getBucket(self.bucketName) self.keyExists = "Mad Max" self.keyExistsName = self.keyExists + "_NAME" self.keyExistsVal = "Mel Gibson" self.mediaKeyExists = "IMDB" self.tag1 = "Cop" self.tag2 = "Movie" bucket.setValue(self.keyExists, self.keyExistsVal, self.keyExistsName, "Guy in a leather jacket", [self.tag1, self.tag2], self.dbType) bucket.setValue(self.mediaKeyExists, "www.imdb.com", self.mediaKeyExists, "", [self.tag2], self.mediaType) #Note: original test used None for name BUT name has a unique index bucket.setValue("Pallindrome", "Emordnillap", "Eman", "", None, self.dbType) self.keyMissing = "Missing" self.keys = [self.keyExists, "IMDB", "Pallindrome"] self.tags1 = [self.keyExists] self.tags2 = [self.keyExists, "IMDB"] bucket.save()
def test_create_bucket(self): bucket_name = 'test_bucket_create' bucket = Bucket.make(bucket_name) storageService = MongoStorageService() bucket.bucket_name = bucket_name bucket.save() bucket = None bucket = storageService.getBucket(bucket_name) self.assertIsNotNone(bucket) self.assertEqual(bucket.bucket_name, bucket_name) self.assertEqual(bucket.tag_maps, {}) self.assertEqual(bucket.name_map, {}) self.assertEqual(bucket.adaptor_map, {})