import pytest from slz_downloader.dsp.entities import ReportMeta, S3Path def test_s3_path_not_enough_parameters(): with pytest.raises(TypeError): S3Path('bucket', 'path') def test_s3_path_too_many_parameters(): with pytest.raises(TypeError): S3Path('bucket', 'path', 'report', 'extension') def test_s3_path_url(): entity = S3Path( bucket='sme-archive', path='apple/2019-01-01', name='report.txt', ) assert 's3://sme-archive/apple/2019-01-01/report.txt' == entity.url def test_s3_path_key(): entity = S3Path( bucket='sme-archive', path='apple/2019-01-01', name='report.txt', ) assert 'apple/2019-01-01/report.txt' == entity.key def test_report_meta_to_dict(): meta = ReportMeta( actual_size=0, files=[], expected_size=0, destination_path=S3Path('archive', 'path', 'report'), destination_path_quarantine=S3Path('archive', 'path', 'report'), destination_decompressed_path_quarantine=None, destination_corrupted_path=S3Path('corrupted', 'path', 'report') ) expected = { 'actual_size': 0, 'files': [], 'expected_size': 0, 'destination_corrupted_path': { 'bucket': 'corrupted', 'name': 'report', 'path': 'path', }, 'destination_decompressed_path_quarantine': None, 'destination_path': { 'bucket': 'archive', 'name': 'report', 'path': 'path', }, 'destination_path_quarantine': { 'bucket': 'archive', 'name': 'report', 'path': 'path', }, 'support_files': None, 'meta_data': None } assert expected == meta.to_dict()