Пример #1
0
def test_delete_other_user(dummy_user):
    # No integration test possible because the application flow currently
    # doesn't allow for this scenario to occur.
    _, user_id = save(dummy_user)
    mock_request = Mock()
    type(mock_request).authenticated_userid = PropertyMock(
        return_value=str(uuid.uuid4()))

    user_handler = UserHandler(get_user_by_id(user_id), mock_request)

    with pytest.raises(HTTPNoContent):
        user_handler.delete()

    assert get_user_by_id(user_id) is None
Пример #2
0
 def write(msg, fromUser, lang):
     user_handler = UserHandler()
     if len(msg.split()) == 0:
         content = Resource.getMsg("EmptyMsg")
     elif (user_handler.verify_user(fromUser) == 0):
         # Qulified User
         if int(DBHandler().insert(
                 "INSERT into Notepad VALUES (null, '%s', null, '%s')" %
             (fromUser, msg))) == 1:
             content = Resource.getMsg("Recorded")
         else:
             content = Resource.getMsg("FailRecord")
     else:
         content = Resource.getMsg("QualifiedUser")
     return content
Пример #3
0
 def remove(msg, fromUser, lang):
     user_handler = UserHandler()
     if (user_handler.verify_user(fromUser) == 0):
         # Qulified User
         note_set = DBHandler().select(
             "SELECT IND from Notepad WHERE Open_ID = '%s'" % fromUser)
         index = 1
         for line in note_set[1]:
             if msg == str(index):
                 DBHandler().delete("DELETE from Notepad where IND = '%d'" %
                                    line[0])
             index += 1
         content = Resource.getMsg("Removed")
     else:
         content = Resource.getMsg("QualifiedUser")
     return content
Пример #4
0
 def check(msg, fromUser, lang):
     content = ""
     user_handler = UserHandler()
     if (user_handler.verify_user(fromUser) == 0):
         # Qulified User
         note_set = DBHandler().select(
             "SELECT RecoreData,Note from Notepad WHERE Open_ID = '%s'" %
             fromUser)
         index = 1
         for line in note_set[1]:
             content = content + str(index) + ") " + line[0].strftime(
                 "%Y-%m-%d %H:%M:%S") + " " + line[1] + "\n"
             index += 1
     else:
         content = Resource.getMsg("QualifiedUser")
     return content
Пример #5
0
    def run(self, arg_input_video_folder, arg_user_root_folder, arg_selection):
        logger.info("Running Application with video folder: " +
                    arg_input_video_folder + " user folder: " +
                    arg_user_root_folder + "\n")

        # Create objects
        tmp_motion_start_detector = MotionStartDetector.MotionStartDetector()
        tmp_user_handler = UserHandler.UserHandler()
        tmp_motion_time_user_matching = MotionTimeUserMatching.MotionTimeUserMatching(
        )
        tmp_full_clip_cut_extractor = FullClipExtractor.FullClipExtractor()
        tmp_tracker_clip_extractor = TrackerClipExtractor.TrackerClipExtractor(
        )

        if not os.path.exists(arg_input_video_folder):
            raise ValueError("Video folder is not a valid folder: " +
                             arg_input_video_folder)
        if not os.path.exists(arg_user_root_folder):
            raise ValueError("User folder is not a valid folder: " +
                             arg_user_root_folder)

        if ActionOptions.GENERATE_MOTION_FILES.value in arg_selection:
            tmp_motion_start_detector.create_motion_start_files(
                arg_input_video_folder)

        if ActionOptions.INIT_USERS.value in arg_selection:
            tmp_user_handler.init(arg_user_root_folder)

        if ActionOptions.MATCH_LOCATION_IN_MOTION_FILES.value in arg_selection:
            tmp_motion_time_user_matching.match_motion_start_times_with_users(
                arg_input_video_folder, tmp_user_handler)

        if ActionOptions.GENERATE_FULL_CLIP_OUTPUTS.value in arg_selection:
            clip_specification_list = tmp_user_handler.create_clip_specifications(
                ClipTypes.FULL_CLIP)
            tmp_full_clip_cut_extractor.extract_clips_from_list(
                clip_specification_list)

        if ActionOptions.GENERATE_TRACKER_CLIP_OUTPUTS.value in arg_selection:
            clip_specification_list = tmp_user_handler.create_clip_specifications(
                ClipTypes.TRACKER_CLIP)
            tmp_tracker_clip_extractor.extract_clips_from_list(
                clip_specification_list)