Esempio n. 1
0
    def test_get_spatial_dataset_engine_with_site(self, mock_sds_model, mock_initialize_engine_object):
        name = 'foo'
        mock_site_sds = mock.MagicMock()
        mock_site_sds.name = 'foo'
        mock_sds_model.objects.all.return_value = [mock_site_sds]
        mock_sdo = mock.MagicMock()
        mock_sdo.public_endpoint = mock_site_sds.public_endpoint
        mock_initialize_engine_object.return_value = mock_sdo

        ret = get_spatial_dataset_engine(name=name, app_class=None)

        self.assertEquals(mock_sdo, ret)
        mock_initialize_engine_object.assert_called_once_with(engine=mock_site_sds.engine,
                                                              endpoint=mock_site_sds.endpoint,
                                                              apikey=mock_site_sds.apikey,
                                                              username=mock_site_sds.username,
                                                              password=mock_site_sds.password)
Esempio n. 2
0
    def test_get_spatial_dataset_engine_with_site(self, mock_sds_model, mock_initialize_engine_object):
        name = 'foo'
        mock_site_sds = mock.MagicMock()
        mock_site_sds.name = 'foo'
        mock_sds_model.objects.all.return_value = [mock_site_sds]
        mock_sdo = mock.MagicMock()
        mock_sdo.public_endpoint = mock_site_sds.public_endpoint
        mock_initialize_engine_object.return_value = mock_sdo

        ret = get_spatial_dataset_engine(name=name, app_class=None)

        self.assertEqual(mock_sdo, ret)
        mock_initialize_engine_object.assert_called_once_with(engine=mock_site_sds.engine,
                                                              endpoint=mock_site_sds.endpoint,
                                                              apikey=mock_site_sds.apikey,
                                                              username=mock_site_sds.username,
                                                              password=mock_site_sds.password)
Esempio n. 3
0
    def test_get_spatial_dataset_engine_with_app(self, mock_issubclass, mock_initialize_engine_object):
        from tethys_apps.base.app_base import TethysAppBase

        name = 'foo'
        mock_app_class = mock.MagicMock()
        mock_app_sds = mock.MagicMock()
        mock_app_sds.name = 'foo'
        mock_app_class().spatial_dataset_services.return_value = [mock_app_sds]
        mock_issubclass.return_value = True
        mock_initialize_engine_object.return_value = True

        ret = get_spatial_dataset_engine(name=name, app_class=mock_app_class)

        self.assertTrue(ret)
        mock_issubclass.assert_called_once_with(mock_app_class, TethysAppBase)
        mock_initialize_engine_object.assert_called_once_with(engine=mock_app_sds.engine,
                                                              endpoint=mock_app_sds.endpoint,
                                                              apikey=mock_app_sds.apikey,
                                                              username=mock_app_sds.username,
                                                              password=mock_app_sds.password)
Esempio n. 4
0
    def test_get_spatial_dataset_engine_with_app(self, mock_issubclass, mock_initialize_engine_object):
        from tethys_apps.base.app_base import TethysAppBase

        name = 'foo'
        mock_app_class = mock.MagicMock()
        mock_app_sds = mock.MagicMock()
        mock_app_sds.name = 'foo'
        mock_app_class().spatial_dataset_services.return_value = [mock_app_sds]
        mock_issubclass.return_value = True
        mock_initialize_engine_object.return_value = True

        ret = get_spatial_dataset_engine(name=name, app_class=mock_app_class)

        self.assertTrue(ret)
        mock_issubclass.assert_called_once_with(mock_app_class, TethysAppBase)
        mock_initialize_engine_object.assert_called_once_with(engine=mock_app_sds.engine,
                                                              endpoint=mock_app_sds.endpoint,
                                                              apikey=mock_app_sds.apikey,
                                                              username=mock_app_sds.username,
                                                              password=mock_app_sds.password)