コード例 #1
0
    def test_zip_with_date(self):
        filename = 'test.zip'

        expected = 'test_e3b0c4.zip'
        actual = ImapClient._unique_filename(filename, date='1-17-18')

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b''),
            mock.call(b'1-17-18'),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()
コード例 #2
0
    def test_tar_gz_no_from_addr(self):
        filename = 'test.tar.gz'

        expected = 'test_e3b0c4.tar.gz'
        actual = ImapClient._unique_filename(filename)

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b''),
            mock.call(b''),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()
コード例 #3
0
    def test_zip_with_from_addr(self):
        filename = 'test.zip'

        expected = 'test_e3b0c4.zip'
        actual = ImapClient._unique_filename(filename,
                                             from_addr='*****@*****.**')

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b'*****@*****.**'),
            mock.call(b''),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()
コード例 #4
0
    def test_filename_includes_spaces_tar_gz(self):
        filename = 'john doe smith.tar.gz'

        expected = 'john_doe_smith_e3b0c4.tar.gz'
        actual = ImapClient._unique_filename(filename,
                                             from_addr='*****@*****.**',
                                             date='1-17-18')

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b'*****@*****.**'),
            mock.call(b'1-17-18'),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()
コード例 #5
0
    def test_quoted_printable_encoded_filename_tar_gz(self):
        filename = '=?UTF-8?Q?john=5Fdoe=5Fsmith.tar.gz?='

        expected = 'john_doe_smith_e3b0c4.tar.gz'
        actual = ImapClient._unique_filename(filename,
                                             from_addr='*****@*****.**',
                                             date='1-17-18')

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b'*****@*****.**'),
            mock.call(b'1-17-18'),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()
コード例 #6
0
    def test_b64_encoded_filename_tar_gz(self):
        filename = '=?UTF-8?b?dGVzdC50YXIuZ3oK?='

        expected = 'test_e3b0c4.tar.gz'
        actual = ImapClient._unique_filename(filename,
                                             from_addr='*****@*****.**',
                                             date='1-17-18')

        assert expected == actual
        self.mock_sha256.return_value.update.assert_has_calls([
            mock.call(b'*****@*****.**'),
            mock.call(b'1-17-18'),
        ])
        self.mock_sha256.return_value.hexdigest.assert_called_once_with()