def setUp(self): super(TestRootController, self).setUp() self.controller = RootController()
class TestRootController(trove_testtools.TestCase): def setUp(self): super(TestRootController, self).setUp() self.controller = RootController() @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_index(self, service_get_datastore, service_load_root_controller): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) root_controller = Mock() ret = Mock() root_controller.root_index = Mock(return_value=ret) service_load_root_controller.return_value = root_controller self.assertTrue(ret, self.controller.index(req, tenant_id, uuid)) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager) root_controller.root_index.assert_called_with( req, tenant_id, uuid, is_cluster) @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_create(self, service_get_datastore, service_load_root_controller): req = Mock() body = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) root_controller = Mock() ret = Mock() root_controller.root_create = Mock(return_value=ret) service_load_root_controller.return_value = root_controller self.assertTrue( ret, self.controller.create(req, tenant_id, uuid, body=body)) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager) root_controller.root_create.assert_called_with( req, body, tenant_id, uuid, is_cluster) @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_create_with_no_root_controller(self, service_get_datastore, service_load_root_controller): req = Mock() body = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) service_load_root_controller.return_value = None self.assertRaises( NoSuchOptError, self.controller.create, req, tenant_id, uuid, body=body) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager)
class TestRootController(trove_testtools.TestCase): def setUp(self): super(TestRootController, self).setUp() self.controller = RootController() @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_index(self, service_get_datastore, service_load_root_controller): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) root_controller = Mock() ret = Mock() root_controller.root_index = Mock(return_value=ret) service_load_root_controller.return_value = root_controller self.assertTrue(ret, self.controller.index(req, tenant_id, uuid)) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager) root_controller.root_index.assert_called_with(req, tenant_id, uuid, is_cluster) @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_create(self, service_get_datastore, service_load_root_controller): req = Mock() body = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) root_controller = Mock() ret = Mock() root_controller.root_create = Mock(return_value=ret) service_load_root_controller.return_value = root_controller self.assertTrue( ret, self.controller.create(req, tenant_id, uuid, body=body)) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager) root_controller.root_create.assert_called_with(req, body, tenant_id, uuid, is_cluster) @patch.object(RootController, "load_root_controller") @patch.object(RootController, "_get_datastore") def test_create_with_no_root_controller(self, service_get_datastore, service_load_root_controller): req = Mock() body = Mock() tenant_id = Mock() uuid = utils.generate_uuid() ds_manager = Mock() is_cluster = Mock() service_get_datastore.return_value = (ds_manager, is_cluster) service_load_root_controller.return_value = None self.assertRaises(NoSuchOptError, self.controller.create, req, tenant_id, uuid, body=body) service_get_datastore.assert_called_with(tenant_id, uuid) service_load_root_controller.assert_called_with(ds_manager)
def setUp(self): super(TestRootController, self).setUp() self.context = trove_testtools.TroveTestContext(self) self.controller = RootController()