def test_find_instance_by_name(self): from redisapi.storage import MongoStorage storage = MongoStorage() instance = Instance( "xname", "plan", [{"host": "host", "container_id": "id", "port": "port"}]) storage.add_instance(instance) result = storage.find_instance_by_name(instance.name) self.assertEqual(instance.endpoints[0]["container_id"], result.endpoints[0]["container_id"]) storage.remove_instance(instance)
def test_find_instance_by_name(self): from redisapi.storage import MongoStorage storage = MongoStorage() instance = Instance("xname", "plan", [{ "host": "host", "container_id": "id", "port": "port" }]) storage.add_instance(instance) result = storage.find_instance_by_name(instance.name) self.assertEqual(instance.endpoints[0]["container_id"], result.endpoints[0]["container_id"]) storage.remove_instance(instance)
def test_remove_instance(self): from redisapi.storage import MongoStorage storage = MongoStorage() instance = Instance( "xname", "plan", [{"host": "host", "container_id": "id", "port": "port"}]) storage.add_instance(instance) result = storage.find_instance_by_name(instance.name) endpoint = instance.endpoints[0] self.assertEqual(endpoint["container_id"], result.endpoints[0]["container_id"]) storage.remove_instance(instance) length = storage.conn()['redisapi']['instances'].find( {"name": instance.name}).count() self.assertEqual(length, 0)
def test_remove_instance(self): from redisapi.storage import MongoStorage storage = MongoStorage() instance = Instance("xname", "plan", [{ "host": "host", "container_id": "id", "port": "port" }]) storage.add_instance(instance) result = storage.find_instance_by_name(instance.name) endpoint = instance.endpoints[0] self.assertEqual(endpoint["container_id"], result.endpoints[0]["container_id"]) storage.remove_instance(instance) length = storage.db()['instances'].find({ "name": instance.name }).count() self.assertEqual(length, 0)