示例#1
0
文件: tests.py 项目: tilacog/paranoid
    def test_can_check_mime(self, mock_magic):
        "Validator must call `magic.from_file` using it's file_path attribute"

        validator = DocumentValidatorProvider(*self.initial_data)
        validator._has_right_type()

        mock_magic.from_file.assert_called_once_with(
            self.initial_data[0],
            mime=True,
        )
示例#2
0
文件: tests.py 项目: tilacog/paranoid
    def test_can_detect_invalid_mime(self, mock_magic):
        """
        If given an invalid document `validator.has_right_type` method should
        return False
        """

        # magic.from_file return bytes
        mock_magic.from_file.return_value = b'invalid/mime'

        # Run validation
        validator = DocumentValidatorProvider(*self.initial_data)

        result = validator._has_right_type()
        self.assertFalse(result)