예제 #1
0
 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()
예제 #2
0
 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()
예제 #3
0
 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'])
예제 #4
0
 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')
예제 #5
0
 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()
예제 #6
0
 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', [])
예제 #7
0
 def test_create_map(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.newResourceID = 'map_id';
     maps_service.post_maps = mock.MagicMock(return_value=res)
     result = portal.create_map([Layer()], 3857, 'map', (0, 0), (-180, -90, 180, 90))
     self.assertEqual(result, 'map_id')
예제 #8
0
 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'])
예제 #9
0
 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()
예제 #10
0
 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()
예제 #11
0
 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', [])
예제 #12
0
 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')
예제 #13
0
 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()
예제 #14
0
 def test_create_map(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.newResourceID = 'map_id'
     maps_service.post_maps = mock.MagicMock(return_value=res)
     result = online.create_map([Layer()], 3857, 'map', (0, 0),
                                (-180, -90, 180, 90))
     self.assertEqual(result, 'map_id')
예제 #15
0
 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')])
예제 #16
0
 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()
예제 #17
0
 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()
예제 #18
0
 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()
예제 #19
0
 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()
예제 #20
0
 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()
예제 #21
0
 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)
예제 #22
0
 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')])
예제 #23
0
 def test_deleterole_exception(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()
     managment.delete_role = mock.MagicMock(return_value=re)
     with self.assertRaises(Exception):
         portal.delete_role('test')
     managment.delete_role.assert_called_once()
예제 #24
0
 def test_deleteroles_exception(self):
     server = self.server
     server._apifactory = MagicMock()
     managment = MagicMock()
     server._apifactory.security_management = MagicMock(
         return_value=managment)
     re = MethodResult()
     managment.put_roles = MagicMock(return_value=re)
     with self.assertRaises(Exception):
         server.delete_roles(['test'])
     managment.put_roles.assert_called_once()
예제 #25
0
 def test_updaterole_exception(self):
     server = self.server
     server._apifactory = MagicMock()
     managment = MagicMock()
     server._apifactory.security_management = MagicMock(
         return_value=managment)
     re = MethodResult()
     managment.put_role = MagicMock(return_value=re)
     with self.assertRaises(Exception):
         server.update_role('test', description='test')
     managment.put_role.assert_called_once()
예제 #26
0
 def test_createuser_exception(self):
     server = self.server
     server._apifactory = MagicMock()
     managment = MagicMock()
     server._apifactory.security_management = MagicMock(
         return_value=managment)
     re = MethodResult()
     managment.post_users = MagicMock(return_value=re)
     with self.assertRaises(Exception):
         server.create_user('test', 'test')
     managment.post_users.assert_called_once()