コード例 #1
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
    def test_import_permissions(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url,
                                                  '*****@*****.**', 'abcdef',
                                                  'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            response = mscolab_create_content(self.app,
                                              self.url,
                                              data,
                                              path_name='p1')
            assert response.status == '200 OK'
            response = mscolab_create_content(self.app,
                                              self.url,
                                              data,
                                              path_name='p2')
            assert response.status == '200 OK'

            url = url_join(self.url, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'p1':
                    data['import_p_id'] = p['p_id']
                if p['path'] == 'p2':
                    data['current_p_id'] = p['p_id']
            url = url_join(self.url, 'import_permissions')
            response = self.app.test_client().post(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            assert response["success"] is True
コード例 #2
0
ファイル: test_server.py プロジェクト: plant99/MSS
    def test_get_projects(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, MSCOLAB_URL_TEST, '*****@*****.**', 'abcdef', 'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            response = mscolab_create_content(self.app, MSCOLAB_URL_TEST, data, path_name='f7')
            assert response.status == '200 OK'
            response = mscolab_create_content(self.app, MSCOLAB_URL_TEST, data, path_name='f8')
            assert response.status == '200 OK'

            url = url_join(MSCOLAB_URL_TEST, 'projects')
            response = self.app.test_client().get(url, data=data)
            response = json.loads(response.get_data(as_text=True))
            assert len(response['projects']) == 2
コード例 #3
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
 def test_token_dependency_to_project(self):
     """
     creates a user, creates a project, checks that there is only 1 project
     fetches a valid token from an other user
     replaces the token by keeping the user information
     finds only projects related to the changed token
     """
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, self.url,
                                               '*****@*****.**', 'user',
                                               'user')
         assert response.status == '200 OK'
         data_1 = json.loads(response.get_data(as_text=True))
         response = mscolab_create_content(self.app,
                                           self.url,
                                           data_1,
                                           path_name='data_1')
         assert response.status == '200 OK'
         url = url_join(self.url, 'projects')
         response = self.app.test_client().get(url, data=data_1)
         assert response.status == '200 OK'
         response = json.loads(response.get_data(as_text=True))
         assert len(response['projects']) == 1
         response = mscolab_login(self.app, self.url, 'a', 'a')
         data_a = json.loads(response.get_data(as_text=True))
         data_1['token'] = data_a['token']
         url = url_join(self.url, 'projects')
         response = self.app.test_client().get(url, data=data_1)
         response = json.loads(response.get_data(as_text=True))
         assert len(response['projects']) == 3
コード例 #4
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
 def test_uniqueness_of_user_id(self):
     """
     creates a user, creates a project, removes the user
     creates a different new user, checks for projects
     should not find anything
     """
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, self.url,
                                               '*****@*****.**', 'abcdef',
                                               'alpha')
         assert response.status == '200 OK'
         data = json.loads(response.get_data(as_text=True))
         response = mscolab_create_content(self.app,
                                           self.url,
                                           data,
                                           path_name='owns_alpha')
         assert response.status == '200 OK'
         mscolab_delete_user(self.app, self.url, '*****@*****.**',
                             'abcdef')
         response = mscolab_register_and_login(self.app, self.url,
                                               '*****@*****.**', 'abcdef',
                                               'delta')
         assert response.status == '200 OK'
         data = json.loads(response.get_data(as_text=True))
         url = url_join(self.url, 'projects')
         response = self.app.test_client().get(url, data=data)
         response = json.loads(response.get_data(as_text=True))
         assert len(response['projects']) == 0
コード例 #5
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
    def test_get_users_with_permission(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url,
                                                  '*****@*****.**', 'abcdef',
                                                  'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            response = mscolab_create_content(self.app,
                                              self.url,
                                              data,
                                              path_name='f15')
            assert response.status == '200 OK'

            url = url_join(self.url, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'f15':
                    data['p_id'] = p['p_id']
                    break

            url = url_join(self.url, 'users_with_permission')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            assert response['success'] is True
            assert response['users'] == []
コード例 #6
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
 def test_get_project_details(self):
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, self.url,
                                               '*****@*****.**', 'abcdef',
                                               'alpha')
         assert response.status == '200 OK'
         data = json.loads(response.get_data(as_text=True))
         auth_data = data
         response = mscolab_create_content(self.app,
                                           self.url,
                                           data,
                                           path_name='f13')
         assert response.status == '200 OK'
         url = url_join(self.url, 'projects')
         response = self.app.test_client().get(url, data=data)
         assert response.status == '200 OK'
         response = json.loads(response.get_data(as_text=True))
         for p in response['projects']:
             if p['path'] == 'f13':
                 auth_data['p_id'] = p['p_id']
                 break
         url = url_join(self.url, 'project_details')
         response = self.app.test_client().get(url, data=auth_data)
         assert response.status == '200 OK'
         response = json.loads(response.get_data(as_text=True))
         assert response == {
             'description': 'f13',
             'id': auth_data['p_id'],
             'path': 'f13'
         }
コード例 #7
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
    def test_authorized_users(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url,
                                                  '*****@*****.**', 'abcdef',
                                                  'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            auth_data = data
            response = mscolab_create_content(self.app,
                                              self.url,
                                              data,
                                              path_name='f10')
            assert response.status == '200 OK'
            url = url_join(self.url, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'f10':
                    auth_data['p_id'] = p['p_id']
                    break

            url = url_join(self.url, 'authorized_users')
            response = self.app.test_client().get(url, data=auth_data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            assert response['users'] == [{
                'access_level': 'creator',
                'username': '******'
            }]
コード例 #8
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
    def test_get_change_content(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url,
                                                  '*****@*****.**', 'abcdef',
                                                  'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            response = mscolab_create_content(self.app,
                                              self.url,
                                              data,
                                              path_name='f15')
            assert response.status == '200 OK'
            url = url_join(self.url, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'f15':
                    data['p_id'] = p['p_id']
                    break

            url = url_join(self.url, 'get_change_content')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = response.get_data(as_text=True)
            # ToDo add a test with two revisions
            assert response == 'False'
コード例 #9
0
ファイル: test_server.py プロジェクト: nakul-shahdadpuri/MSS
 def test_update_project(self):
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, self.url,
                                               '*****@*****.**', 'abcdef',
                                               'alpha')
         assert response.status == '200 OK'
         data = json.loads(response.get_data(as_text=True))
         response = mscolab_create_content(self.app,
                                           self.url,
                                           data,
                                           path_name='f16')
         assert response.status == '200 OK'
         url = url_join(self.url, 'projects')
         response = self.app.test_client().get(url, data=data)
         assert response.status == '200 OK'
         response = json.loads(response.get_data(as_text=True))
         for p in response['projects']:
             if p['path'] == 'f16':
                 data['p_id'] = p['p_id']
                 break
         data['attribute'] = 'path'
         data['value'] = 'example_flight_path'
         url = url_join(self.url, 'update_project')
         response = self.app.test_client().post(url, data=data)
         assert response.status == '200 OK'
         content = """\
                 <?xml version="1.0" encoding="utf-8"?>
                   <FlightTrack>
                     <Name>F14 test example</Name>
                     <ListOfWaypoints>
                       <Waypoint flightlevel="100.0" lat="55.15" location="A1" lon="-25.74">
                         <Comments>Takeoff</Comments>
                       </Waypoint>
                       <Waypoint flightlevel="350" lat="42.99" location="A2" lon="-12.1">
                         <Comments></Comments>
                       </Waypoint>
                       </ListOfWaypoints>
                   </FlightTrack>"""
         # not sure if the update API should do this
         # data['attribute'] = "content"
         # data['value'] = content
         # url = url_join(self.url, 'update_project')
         # response = self.app.test_client().post(url, data=data)
         # assert response.status == '200 OK'
         user = User.query.filter_by(emailid='*****@*****.**').first()
         self.fm.save_file(int(data['p_id']), content, user, "new")
コード例 #10
0
ファイル: test_server.py プロジェクト: plant99/MSS
    def test_delete_project(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, MSCOLAB_URL_TEST, '*****@*****.**', 'abcdef', 'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            auth_data = data
            response = mscolab_create_content(self.app, MSCOLAB_URL_TEST, data, path_name='f12')
            assert response.status == '200 OK'
            url = url_join(MSCOLAB_URL_TEST, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'f12':
                    auth_data['p_id'] = p['p_id']
                    break

            url = url_join(MSCOLAB_URL_TEST, 'delete_project')
            response = self.app.test_client().post(url, data=auth_data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            assert response['success'] is True
コード例 #11
0
ファイル: test_server.py プロジェクト: plant99/MSS
    def test_get_all_changes(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, MSCOLAB_URL_TEST, '*****@*****.**', 'abcdef', 'alpha')
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            response = mscolab_create_content(self.app, MSCOLAB_URL_TEST, data, path_name='f14')
            assert response.status == '200 OK'
            url = url_join(MSCOLAB_URL_TEST, 'projects')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            response = json.loads(response.get_data(as_text=True))
            for p in response['projects']:
                if p['path'] == 'f14':
                    data['p_id'] = p['p_id']
                    break

            url = url_join(MSCOLAB_URL_TEST, 'get_all_changes')
            response = self.app.test_client().get(url, data=data)
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            assert data['success'] is True
            # ToDo check 2 changes
            assert data['changes'] == []