def test_get_dataset_engine_dataset_services(self, mock_ds_model_object_all, mock_initialize_engine_object, mock_subclass): mock_name = 'foo' mock_subclass.return_value = False mock_init_return = mock.MagicMock() mock_initialize_engine_object.return_value = mock_init_return mock_site_dataset_services = mock.MagicMock() mock_site_dataset_services.name = 'foo' mock_ds_model_object_all.return_value = [mock_site_dataset_services] mock_init_return.public_endpoint = mock_site_dataset_services.public_endpoint ret = get_dataset_engine(mock_name, app_class=None) mock_initialize_engine_object.assert_called_with(engine=mock_site_dataset_services.engine, endpoint=mock_site_dataset_services.endpoint, apikey=mock_site_dataset_services.apikey, username=mock_site_dataset_services.username, password=mock_site_dataset_services.password, request=None) self.assertEquals(mock_init_return, ret)
def test_get_dataset_engine_dataset_services(self, mock_ds_model_object_all, mock_initialize_engine_object, mock_subclass): mock_name = 'foo' mock_subclass.return_value = False mock_init_return = mock.MagicMock() mock_initialize_engine_object.return_value = mock_init_return mock_site_dataset_services = mock.MagicMock() mock_site_dataset_services.name = 'foo' mock_ds_model_object_all.return_value = [mock_site_dataset_services] mock_init_return.public_endpoint = mock_site_dataset_services.public_endpoint ret = get_dataset_engine(mock_name, app_class=None) mock_initialize_engine_object.assert_called_with(engine=mock_site_dataset_services.engine, endpoint=mock_site_dataset_services.endpoint, apikey=mock_site_dataset_services.apikey, username=mock_site_dataset_services.username, password=mock_site_dataset_services.password, request=None) self.assertEqual(mock_init_return, ret)
def test_get_dataset_engine_app_dataset(self, mock_initialize_engine_object, mock_subclass): from tethys_apps.base.app_base import TethysAppBase mock_name = 'foo' mock_app_class = mock.MagicMock() mock_subclass.return_value = True mock_app_dataset_services = mock.MagicMock() mock_app_dataset_services.name = 'foo' mock_app_class().dataset_services.return_value = [mock_app_dataset_services] mock_initialize_engine_object.return_value = True ret = get_dataset_engine(mock_name, mock_app_class) mock_subclass.assert_called_once_with(mock_app_class, TethysAppBase) mock_initialize_engine_object.assert_called_with(engine=mock_app_dataset_services.engine, endpoint=mock_app_dataset_services.endpoint, apikey=mock_app_dataset_services.apikey, username=mock_app_dataset_services.username, password=mock_app_dataset_services.password, request=None) self.assertTrue(ret)