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()
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()
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()
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()
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()
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()