def test_delete_maps(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() maps_service = mock.MagicMock() portal._portal.maps_service = mock.MagicMock(return_value=maps_service) res = MethodResult() res.succeed = True maps_service.delete_maps = mock.MagicMock(return_value=res) portal.delete_maps(['map_id']) maps_service.delete_maps.assert_called_once_with(['map_id'])
def test_createuser(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() managment = mock.MagicMock() portal._portal.security_management = mock.MagicMock(return_value=managment) re = MethodResult() re.succeed = True managment.post_users = mock.MagicMock(return_value=re) portal.create_user('test', 'test') managment.post_users.assert_called_once()
def test_share_map_public(self): online = Online('test', 'test') online._online = mock.MagicMock() maps_service = mock.MagicMock() online._online.maps_service = mock.MagicMock(return_value=maps_service) res = MethodResult() res.succeed = True maps_service.put_map_sharesetting = mock.MagicMock(return_value=res) online.share_map('map_id', True) maps_service.put_map_sharesetting.assert_called_once()
def test_delete_maps(self): online = self.online online._online = mock.MagicMock() maps_service = mock.MagicMock() online._online.maps_service = mock.MagicMock(return_value=maps_service) res = MethodResult() res.succeed = True maps_service.delete_maps = mock.MagicMock(return_value=res) online.delete_maps(['map_id']) maps_service.delete_maps.assert_called_once_with(['map_id'])
def test_config_map_sharesetting(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() maps_services = mock.MagicMock() portal._portal.maps_service = mock.MagicMock(return_value=maps_services) res = MethodResult() res.succeed = True maps_services.put_map_sharesetting = mock.MagicMock(return_value=res) portal.config_map_sharesetting('map_id', []) maps_services.put_map_sharesetting.assert_called_once_with('map_id', [])
def test_deleteroles(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() managment = mock.MagicMock() portal._portal.security_management = mock.MagicMock(return_value=managment) re = MethodResult() re.succeed = True managment.put_roles = mock.MagicMock(return_value=re) portal.delete_roles(['test']) managment.put_roles.assert_called_once()
def test_share_map_private(self): online = self.online online._online = mock.MagicMock() maps_service = mock.MagicMock() online._online.maps_service = mock.MagicMock(return_value=maps_service) res = MethodResult() res.succeed = True maps_service.put_map_sharesetting = mock.MagicMock(return_value=res) online.share_map('map_id', False) maps_service.put_map_sharesetting.assert_called_once()
def test_updaterole(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() managment = mock.MagicMock() portal._portal.security_management = mock.MagicMock(return_value=managment) re = MethodResult() re.succeed = True managment.put_role = mock.MagicMock(return_value=re) portal.update_role('test', description='test') managment.put_role.assert_called_once()
def test_delete_data(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() data_services = mock.MagicMock() portal._portal.datas_service = mock.MagicMock(return_value=data_services) res = MethodResult() res.succeed = True data_services.delete_data = mock.MagicMock(return_value=res) portal.delete_data('data_id') data_services.delete_data.assert_called_once_with('data_id')
def test_delete_datas(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() data_services = mock.MagicMock() portal._portal.datas_service = mock.MagicMock(return_value=data_services) res = MethodResult() res.succeed = True data_services.delete_data = mock.MagicMock(return_value=res) portal.delete_datas(['data_id', 'data_id2']) self.assertEqual(data_services.delete_data.call_count, 2) self.assertEqual(data_services.delete_data.call_args_list, [mock.call('data_id'), mock.call('data_id2')])
def test_config_data_sharesetting_exception(self): portal = Portal('http://localhost:8090/iportal', 'admin', 'Supermap123') portal._portal = mock.MagicMock() data_services = mock.MagicMock() portal._portal.datas_service = mock.MagicMock(return_value=data_services) res = MethodResult() res.succeed = False data_services.put_data_sharesetting = mock.MagicMock(return_value=res) with self.assertRaises(Exception): portal.config_data_sharesetting('data_id', []) data_services.put_data_sharesetting.assert_called_once_with('data_id', [])
def test_delete_data(self): online = self.online online._online = mock.MagicMock() data_services = mock.MagicMock() online._online.datas_service = mock.MagicMock( return_value=data_services) res = MethodResult() res.succeed = True data_services.delete_data = mock.MagicMock(return_value=res) online.delete_data('data_id') data_services.delete_data.assert_called_once_with('data_id')
def test_share_data_private(self): online = self.online online._online = mock.MagicMock() data_services = mock.MagicMock() online._online.datas_service = mock.MagicMock( return_value=data_services) res = MethodResult() res.succeed = True data_services.put_sharesetting = mock.MagicMock(return_value=res) online.share_data('data_id', False) data_services.put_sharesetting.assert_called_once()
def test_deleteuser(self): server = self.server server._apifactory = MagicMock() managment = MagicMock() server._apifactory.security_management = MagicMock( return_value=managment) re = MethodResult() re.succeed = True managment.delete_user = MagicMock(return_value=re) server.delete_user('test') managment.delete_user.assert_called_once()
def test_share_data_public(self): online = Online('test', 'test') online._online = mock.MagicMock() data_services = mock.MagicMock() online._online.datas_service = mock.MagicMock( return_value=data_services) res = MethodResult() res.succeed = True data_services.put_sharesetting = mock.MagicMock(return_value=res) online.share_data('data_id', True) data_services.put_sharesetting.assert_called_once()
def test_grant_privileges_instances(self): server = self.server server._apifactory = MagicMock() managment = MagicMock() server._apifactory.management = MagicMock(return_value=managment) re = MethodResult() re.succeed = True managment.post_authorize = MagicMock(return_value=re) server.grant_privileges_instances( ['test'], authorize_type=AuthorizeType.AUTHENTICATED) managment.post_authorize.assert_called_once()
def test_updaterole(self): server = self.server server._apifactory = MagicMock() managment = MagicMock() server._apifactory.security_management = MagicMock( return_value=managment) re = MethodResult() re.succeed = True managment.put_role = MagicMock(return_value=re) server.update_role('test', description='test') managment.put_role.assert_called_once()
def test_createrole(self): server = self.server server._apifactory = MagicMock() managment = MagicMock() server._apifactory.security_management = MagicMock( return_value=managment) re = MethodResult() re.succeed = True managment.post_roles = MagicMock(return_value=re) server.create_role('test') managment.post_roles.assert_called_once()
def test_create_users_from_csv(self): server = self.server server._apifactory = MagicMock() managment = MagicMock() server._apifactory.security_management = MagicMock( return_value=managment) re = MethodResult() re.succeed = True managment.post_users = MagicMock(return_value=re) server.create_users_from_csv( os.path.join(os.path.dirname(os.path.abspath(__file__)), "serveruser.csv")) self.assertEqual(managment.post_users.call_count, 9)
def test_delete_datas(self): online = self.online online._online = mock.MagicMock() data_services = mock.MagicMock() online._online.datas_service = mock.MagicMock( return_value=data_services) res = MethodResult() res.succeed = True data_services.delete_data = mock.MagicMock(return_value=res) online.delete_datas(['data_id', 'data_id2']) self.assertEqual(data_services.delete_data.call_count, 2) self.assertEqual( data_services.delete_data.call_args_list, [mock.call('data_id'), mock.call('data_id2')])