Пример #1
0
 def test_get_recent_oid(self):
     assert add_user(self.userdata[0], self.userdata[1], self.userdata[2])
     assert add_user(self.anotheruserdata[0], self.anotheruserdata[1],
                     self.anotheruserdata[2])
     with self.app.test_client() as test_client:
         db.init_app(self.app)
         user = get_user(self.userdata[0])
         anotheruser = get_user(self.anotheruserdata[0])
         operation, token = self._create_operation(test_client,
                                                   self.userdata)
         op_id = get_recent_op_id(self.fm, user)
         assert op_id == operation.id
         op_id = get_recent_op_id(self.fm, anotheruser)
         assert op_id is None
Пример #2
0
 def test_get_operation(self):
     with self.app.test_client():
         self._create_operation(flight_path="operation9")
         op_id = get_recent_op_id(self.fm, self.user)
         assert self.fm.get_file(op_id, self.user) is not False
         user2 = User.query.filter_by(emailid=self.userdata2[0]).first()
         assert self.fm.get_file(op_id, user2) is False
Пример #3
0
 def test_modify_operation(self):
     with self.app.test_client():
         self._create_operation(flight_path="path")
         op_id = get_recent_op_id(self.fm, self.user)
         # testing for wrong characters in path like ' ', '/'
         assert self.fm.update_operation(op_id, 'path', 'dummy wrong', self.user) is False
         assert self.fm.update_operation(op_id, 'path', 'dummy/wrong', self.user) is False
         assert self.fm.update_operation(op_id, 'path', 'dummy', self.user) is True
         assert os.path.exists(os.path.join(mscolab_settings.MSCOLAB_DATA_DIR, 'dummy'))
         assert self.fm.update_operation(op_id, 'description', 'dummy', self.user) is True
Пример #4
0
 def test_is_admin(self):
     with self.app.test_client():
         assert self.fm.create_operation('test_path', 'test desc.', self.user) is True
         op_id = get_recent_op_id(self.fm, self.user)
         u_id = self.user.id
         assert self.fm.is_admin(u_id, op_id) is True
         undefined_op_id = 123
         assert self.fm.is_admin(u_id, undefined_op_id) is False
         no_perm_op_id = 2
         assert self.fm.is_admin(u_id, no_perm_op_id) is False
Пример #5
0
 def test_delete_operation(self):
     with self.app.test_client():
         self._create_operation(flight_path="f3")
         op_id = get_recent_op_id(self.fm, self.user)
         assert self.fm.delete_file(op_id, self.user2) is False
         assert self.fm.delete_file(op_id, self.user) is True
         assert self.fm.delete_file(op_id, self.user) is False
         permissions = Permission.query.filter_by(op_id=op_id).all()
         assert len(permissions) == 0
         operations_db = Operation.query.filter_by(id=op_id).all()
         assert len(operations_db) == 0
         changes = Change.query.filter_by(op_id=op_id).all()
         assert len(changes) == 0
         messages = Message.query.filter_by(op_id=op_id).all()
         assert len(messages) == 0
Пример #6
0
 def test_authorized_users(self):
     with self.app.test_client():
         self._create_operation(flight_path="operation10",
                                content=self.content1)
         op_id = get_recent_op_id(self.fm, self.user)
         assert len(self.fm.get_authorized_users(op_id)) == 1