Пример #1
0
    def test_remove_files(self, subproc_mock, os_mock):
        """S3Payload - Shred Temp Directory"""
        S3Payload._shred_temp_directory()
        subproc_mock.assert_called_with(
            ['shred', '--force', '--iterations=1', '--remove', self.temp_file])

        os_mock.assert_called_with(self.temp_dir)
Пример #2
0
def test_read_local_s3_obj_non_gz():
    """S3Payload - Read S3 Object On Disk, non-gzipped"""
    temp_file_path = os.path.join(tempfile.gettempdir(), 's3_test.json')

    with open(temp_file_path, 'w') as temp_file:
        temp_file.write('test line of data')

    for line_num, line in S3Payload._read_downloaded_s3_object(temp_file_path):
        assert_equal(line_num, 1)
        assert_equal(line, 'test line of data')
Пример #3
0
def test_read_s3_failed_remove(_, log_mock):
    """S3Payload - Read S3 Object On Disk, Removal Failure"""

    temp_file_path = os.path.join(tempfile.gettempdir(), 's3_test.json')

    with open(temp_file_path, 'w') as temp_file:
        temp_file.write('test line of data')

    _ = [_ for _ in S3Payload._read_downloaded_s3_object(temp_file_path)]

    log_mock.assert_called_with('Failed to remove temp S3 file: %s', temp_file_path)