def test_remove_destination(self): """Removing a destination should remove it from the router store and the list of destinations on the router.""" router_config = self.create_router_config() router = Router(self.api, router_config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) yield router.save() self.assertIn(destination.id, router.destinations) self.assertIn( destination.id, (yield self.api.router_store.get_router_destination_list( router.id)) ) yield destination.delete() self.assertNotIn(destination.id, router.destinations) self.assertNotIn( destination.id, (yield self.api.router_store.get_router_destination_list( router.id)) )
def test_destination_status(self): """Getting the destination status should return the configuration of the destination""" router_config = self.create_router_config() router = Router(self.api, router_config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) self.assertEqual(destination_config, (yield destination.status()))
def test_get_destination_list(self): """Getting the destination list of a router should return a list of destination ids for that router""" router_config = self.create_router_config() router = Router(self.api, router_config) router.start(self.api.service) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) self.assertEqual(router.get_destination_list(), [destination.id])
def test_add_destination(self): """add_destination should create and add the destination""" config = self.create_router_config() router = Router(self.api, config) self.assertEqual(router.destinations, {}) destination = router.add_destination(self.create_destination_config()) self.assertEqual(router.destinations, {destination.id: destination})
def test_destinations_are_passed_to_router_worker(self): """The destination configs should be passed to the router worker when the router is started.""" config = self.create_router_config() router = Router(self.api, config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) router.start(self.service) router_worker = self.service.namedServices[router.id] self.assertEqual(router_worker.config['destinations'], [destination.destination_config])
def test_destinations_are_passed_to_router_worker(self): """The destination configs should be passed to the router worker when the router is started.""" config = self.create_router_config() router = Router(self.api, config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) router.start(self.service) router_worker = self.service.namedServices[router.id] self.assertEqual( router_worker.config['destinations'], [destination.destination_config])
def test_destination_save(self): """Saving a destination should save the destination's configuration to the router store""" router_store = self.api.router_store router_config = self.create_router_config() router = Router(self.api, router_config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) self.assertEqual( (yield router_store.get_router_destination_list(router.id)), []) yield destination.save() self.assertEqual( (yield router_store.get_router_destination_list(router.id)), [destination.id])
def test_destinations_restored_on_router_from_id(self): """Creating a router object from id should also restore the destinations for that router""" router_config = self.create_router_config() router = Router(self.api, router_config) router.start(self.api.service) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) yield router.save() restored_router = yield Router.from_id(self.api, router.id) self.assertEqual(router.destinations.keys(), restored_router.destinations.keys()) self.assertEqual( router.destinations[destination.id].destination_config, restored_router.destinations[destination.id].destination_config)
def test_destinations_restored_on_router_from_id(self): """Creating a router object from id should also restore the destinations for that router""" router_config = self.create_router_config() router = Router(self.api, router_config) router.start(self.api.service) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) yield router.save() restored_router = yield Router.from_id(self.api, router.id) self.assertEqual( router.destinations.keys(), restored_router.destinations.keys()) self.assertEqual( router.destinations[destination.id].destination_config, restored_router.destinations[destination.id].destination_config)
def test_save(self): """save should save the configuration of the router and all the destinations into the router store""" config = self.create_router_config() router = Router(self.api, config) dest_config = self.create_destination_config() destination = router.add_destination(dest_config) self.assertEqual((yield self.api.router_store.get_router_list()), []) self.assertEqual( (yield self.api.router_store.get_router_destination_list( router.id)), []) yield router.save() self.assertEqual((yield self.api.router_store.get_router_list()), [router.id]) self.assertEqual( (yield self.api.router_store.get_router_destination_list( router.id)), [destination.id])
def test_save(self): """save should save the configuration of the router and all the destinations into the router store""" config = self.create_router_config() router = Router(self.api, config) dest_config = self.create_destination_config() destination = router.add_destination(dest_config) self.assertEqual((yield self.api.router_store.get_router_list()), []) self.assertEqual( (yield self.api.router_store.get_router_destination_list( router.id)), []) yield router.save() self.assertEqual( (yield self.api.router_store.get_router_list()), [router.id]) self.assertEqual( (yield self.api.router_store.get_router_destination_list( router.id)), [destination.id])
def test_remove_destination(self): """Removing a destination should remove it from the router store and the list of destinations on the router.""" router_config = self.create_router_config() router = Router(self.api, router_config) destination_config = self.create_destination_config() destination = router.add_destination(destination_config) yield router.save() self.assertIn(destination.id, router.destinations) self.assertIn(destination.id, (yield self.api.router_store.get_router_destination_list( router.id))) yield destination.delete() self.assertNotIn(destination.id, router.destinations) self.assertNotIn( destination.id, (yield self.api.router_store.get_router_destination_list( router.id)))