def test_sql_workspace(self): post_func = mock.MagicMock() wsp = PrepareWorkspacePublish(post_func, None) wsp.use_sql_workspace() self.assertTrue(hasattr(wsp.workspace, 'set_server_name')) self.assertTrue(hasattr(wsp.workspace, 'set_workspace_name')) self.assertTrue(hasattr(wsp.workspace, 'set_database_name')) self.assertTrue(hasattr(wsp.workspace, 'set_username')) self.assertTrue(hasattr(wsp.workspace, 'set_password')) self.assertTrue(hasattr(wsp.workspace, 'set_driver')) wsp.workspace.set_server_name('servername') wsp.workspace.set_workspace_name('workspacename') wsp.workspace.set_database_name('databasename') wsp.workspace.set_username('username') wsp.workspace.set_password('password') wsp.workspace.set_driver('SQL Server') wsp.disallow_edit() wsp.avaliable_service_types.RESTMAP.select() wsp.execute() self.assertEqual( str(wsp), """{ "isDataEditable": false, "servicesTypes": [ "RESTMAP" ], "workspaceConnectionInfo": "type=SQL;server=servername;name=workspacename;database=databasename;username=username;password=password;driver=SQL Server" }""") post_func.assert_called_once()
def test_select_file(self): post_func = mock.MagicMock() mng = mock.MagicMock() wsp = PrepareWorkspacePublish(post_func, mng) wsp.use_file_workspace() mng.get_home_path = mock.MagicMock(return_value={'Path': '/iserver'}) world_file = mock.MagicMock() world_file.isDirectory = False world_file.name = 'world.sxwu' world_file.filePath = '/iserver/world.sxwu' mng.get_file_list = mock.MagicMock(return_value=[world_file]) explorer = wsp.workspace.get_file_explorer() explorer[0].select() self.assertEqual( str(wsp), """{ "servicesTypes": [], "workspaceConnectionInfo": "/iserver/world.sxwu" }""")
def test_file_workspace(self): post_func = mock.MagicMock() wsp = PrepareWorkspacePublish(post_func, None) wsp.use_file_workspace() self.assertTrue(hasattr(wsp.workspace, 'set_path')) wsp.workspace.set_path('test') wsp.allow_edit() wsp.avaliable_service_types.RESTDATA.select() wsp.avaliable_service_types.RESTDATA.remove() wsp.avaliable_service_types.RESTMAP.select() wsp.execute() self.assertEqual( str(wsp), """{ "isDataEditable": true, "servicesTypes": [ "RESTMAP" ], "workspaceConnectionInfo": "test" }""") post_func.assert_called_once()
def prepare_workspace_for_publish(self): return PrepareWorkspacePublish(PostWorkspaceExecutor(self._apifactory), self._apifactory.management())