예제 #1
0
파일: test_server.py 프로젝트: plant99/MSS
 def test_uploads(self):
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, MSCOLAB_URL_TEST, '*****@*****.**', 'abcdef', 'alpha')
         assert response.status == '200 OK'
         data, response = mscolab_create_project(self.app, MSCOLAB_URL_TEST, response,
                                                 path='f4', description='f4 test example')
         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'
         projects = json.loads(response.get_data(as_text=True))
         data['p_id'] = projects['projects'][0]['p_id']
         p_id = data['p_id']
         data["message_type"] = 0
         file_name = "fake-text-stream.txt"
         data["file"] = (io.BytesIO(b"some initial text data"), file_name)
         url = url_join(MSCOLAB_URL_TEST, 'message_attachment')
         response = self.app.test_client().post(url, data=data)
         assert response.status == '200 OK'
         data = json.loads(response.get_data(as_text=True))
         assert data['success'] is True
         fn = Path(data['path']).name
         url = "%s/uploads/%s/%s" % (MSCOLAB_URL_TEST, p_id, fn)
         response = self.app.test_client().get(url)
         data = response.get_data(as_text=True)
         assert data == "some initial text data"
         url = "%s/uploads/%s" % (MSCOLAB_URL_TEST, p_id)
         response = self.app.test_client().get(url)
         result = response.get_data(as_text=True)
         assert "404" in result
         url = "%s/uploads/" % (MSCOLAB_URL_TEST)
         response = self.app.test_client().get(url)
         result = response.get_data(as_text=True)
         assert "404" in result
예제 #2
0
 def test_delete_project(self):
     with self.app.app_context():
         response = mscolab_register_and_login(self.app, self.url, 'a', 'a',
                                               'a')
         data, response = mscolab_create_project(
             self.app,
             self.url,
             response,
             path='f3',
             description='f3 test example')
         p_id = get_recent_pid(self.fm, self.user)
         assert p_id == 7
         assert response.status == '200 OK'
         user2 = User.query.filter_by(id=9).first()
         assert self.fm.delete_file(p_id, user2) is False
         assert self.fm.delete_file(p_id, self.user) is True
         assert self.fm.delete_file(p_id, self.user) is False
         permissions = Permission.query.filter_by(p_id=p_id).all()
         assert len(permissions) == 0
         projects_db = Project.query.filter_by(id=p_id).all()
         assert len(projects_db) == 0
         changes = Change.query.filter_by(p_id=p_id).all()
         assert len(changes) == 0
         messages = Message.query.filter_by(p_id=p_id).all()
         assert len(messages) == 0
예제 #3
0
파일: test_server.py 프로젝트: plant99/MSS
    def test_message_attachment(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, MSCOLAB_URL_TEST, '*****@*****.**', 'abcdef', 'alpha')
            assert response.status == '200 OK'
            data, response = mscolab_create_project(self.app, MSCOLAB_URL_TEST, response,
                                                    path='f3', description='f3 test example')
            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'
            projects = json.loads(response.get_data(as_text=True))
            assert projects == {'projects': [{'access_level': 'creator',
                                              'description': 'f3 test example',
                                              'p_id': 7,
                                              'path': 'f3'}]}

            data['p_id'] = projects['projects'][0]['p_id']
            data["message_type"] = 0
            file_name = "fake-text-stream.txt"
            data["file"] = (io.BytesIO(b"some initial text data"), file_name)

            url = url_join(MSCOLAB_URL_TEST, 'message_attachment')
            response = self.app.test_client().post(url, data=data)
            # Todo Example upload
            assert response.status == '200 OK'
            data = json.loads(response.get_data(as_text=True))
            assert data['success'] is True
예제 #4
0
파일: test_server.py 프로젝트: plant99/MSS
 def test_create_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, response = mscolab_create_project(self.app, MSCOLAB_URL_TEST, response,
                                                 path='f1', description='f1 test example')
         assert response.status == '200 OK'
         data = response.get_data(as_text=True)
         assert data == 'True'
예제 #5
0
    def _create_user_data(self, emailid='*****@*****.**'):
        with self.app.app_context():
            self._connect_to_mscolab()
            response = mscolab_register_and_login(self.app, self.url, emailid,
                                                  'abcdef', 'alpha')

            assert response.status == '200 OK'
            data, response = mscolab_create_project(
                self.app,
                self.url,
                response,
                path='f3',
                description='f3 test example')
            assert response.status == '200 OK'
            self._login(emailid, 'abcdef')
            self._activate_project_at_index(0)
예제 #6
0
    def test_delete_project(self):
        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url, 'a', 'a',
                                                  'a')
            assert response.status == '200 OK'
            data, response = mscolab_create_project(
                self.app,
                self.url,
                response,
                path='f3',
                description='f3 test example')
            assert response.status == '200 OK'
            p_id = get_recent_pid(self.fm, self.user)

        # first free number after sseding
        assert p_id == 7
        data = {"token": self.token, "p_id": p_id}
        url = url_join(self.url, 'delete_project')
        res = requests.post(url, data=data).json()
        assert res["success"] is True
예제 #7
0
    def setup(self):
        self.process, self.url, self.app, self.sio, self.cm, self.fm = mscolab_start_server(
            PORTS)
        QtTest.QTest.qWait(500)
        self.application = QtWidgets.QApplication(sys.argv)
        self.window = MSSMscolabWindow(
            data_dir=mscolab_settings.MSCOLAB_DATA_DIR,
            mscolab_server_url=self.url)

        with self.app.app_context():
            response = mscolab_register_and_login(self.app, self.url,
                                                  'a1a@a1a', 'a1a', 'a1a')
            _ = mscolab_create_project(self.app,
                                       self.url,
                                       response,
                                       path='f3',
                                       description='f3 test example')
            self.user = User.query.filter_by(emailid="a1a@a1a").first()
            self.test_p_id = get_recent_pid(self.fm, self.user)
            self.test_sid = 25
            socket_storage = {'s_id': self.test_sid, 'u_id': self.user.id}
            self.sockets = [socket_storage]