<commit_before>import unittest
import uuid
from bitmovin import Bitmovin, DashManifest, ACLEntry, ACLPermission, EncodingOutput, Period, VideoAdaptationSet, \
    AbstractAdaptationSet, FMP4Representation, FMP4RepresentationType, DRMFMP4Representation, Encoding, \
    Stream, StreamInput, MuxingStream, FMP4Muxing, MarlinDRM, AbstractFMP4Representation, WebMRepresentation, \
    WebMRepresentationType, DashMP4Representation
from tests.bitmovin import BitmovinTestCase


class RepresentationTests(BitmovinTestCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()

    @classmethod
    def tearDownClass(cls):
        super().tearDownClass()

    def setUp(self):
        super().setUp()
        self.bitmovin = Bitmovin(self.api_key)
        self.assertIsNotNone(self.bitmovin)
        self.assertTrue(isinstance(self.bitmovin, Bitmovin))
        self.sampleEncoding = self._create_sample_encoding()  # type: Encoding
        self.sampleMuxing = self._create_sample_muxing()  # type: FMP4Muxing
        self.sampleDrm = self._create_sample_drm()  # type: MarlinDRM

    def tearDown(self):
        super().tearDown()

    def test_add_fmp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_fmp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_fmp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_fmp4_representations(sample_representation, representation_resource_response.resource)

    def test_add_drm_fmp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_drm_fmp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_drm_fmp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_drm_fmp4_representations(sample_representation, representation_resource_response.resource)

    def test_add_webm_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_webm_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_webm_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_webm_representations(sample_representation, representation_resource_response.resource)

    def test_add_mp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_mp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_mp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_mp4_representations(sample_representation, representation_resource_response.resource)

    def _compare_manifests(self, first: DashManifest, second: DashManifest):
        self.assertEqual(first.manifestName, second.manifestName)
        self.assertEqual(first.description, second.description)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        return True

    def _compare_periods(self, first: Period, second: Period):
        self.assertEqual(first.start, second.start)
        self.assertEqual(first.duration, second.duration)
        return True

    def _compare_adaptationsets(self, first: AbstractAdaptationSet, second: AbstractAdaptationSet):
        return True

    def _compare_video_adaptationsets(self, first: VideoAdaptationSet, second: VideoAdaptationSet):
        self._compare_adaptationsets(first, second)
        return True

    def _compare_fmp4_representations(self, first: AbstractFMP4Representation, second: AbstractFMP4Representation):
        self.assertEqual(first.type, second.type)
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.segmentPath, second.segmentPath)
        self.assertEqual(first.startSegmentNumber, second.startSegmentNumber)
        self.assertEqual(first.endSegmentNumber, second.endSegmentNumber)
        return True

    def _compare_drm_fmp4_representations(self, first: DRMFMP4Representation, second: DRMFMP4Representation):
        self._compare_fmp4_representations(first, second)
        self.assertEqual(first.drmId, second.drmId)
        return True

    def _compare_webm_representations(self, first: WebMRepresentation, second: WebMRepresentation):
        self.assertEqual(first.type, second.type)
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.segmentPath, second.segmentPath)
        self.assertEqual(first.startSegmentNumber, second.startSegmentNumber)
        return True
    
    def _compare_mp4_representations(self, first: DashMP4Representation, second: DashMP4Representation):
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.filePath, second.filePath)
        return True

    def _compare_encodings(self, first: Encoding, second: Encoding):
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        self.assertEqual(first.encoderVersion, second.encoderVersion)
        self.assertEqual(first.cloudRegion, second.cloudRegion)
        return True

    def _compare_muxings(self, first: FMP4Muxing, second: FMP4Muxing):
        self.assertEqual(first.initSegmentName, second.initSegmentName)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.segmentLength, second.segmentLength)
        self.assertEqual(first.segmentNaming, second.segmentNaming)
        self.assertEqual(first.name, second.name)
        self.assertEqual(second.description, second.description)
        return True

    def _compare_drms(self, first: MarlinDRM, second: MarlinDRM):
        self.assertEqual(first.kid, second.kid)
        self.assertEqual(first.key, second.key)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        return True

    def _get_sample_manifest(self):
        encoding_output = self._get_sample_encoding_output()
        manifest = DashManifest(manifest_name='bitmovin-python_Sample_DASH_Manifest.mpd', outputs=[encoding_output],
                                name='Sample DASH Manifest')

        self.assertIsNotNone(manifest)
        self.assertIsNotNone(manifest.manifestName)
        self.assertIsNotNone(manifest.outputs)
        return manifest

    def _get_sample_encoding_output(self):
        acl_entry = ACLEntry(scope='string', permission=ACLPermission.PUBLIC_READ)

        sample_output = self.utils.get_sample_s3_output()
        s3_output = self.bitmovin.outputs.S3.create(sample_output)
        encoding_output = EncodingOutput(output_id=s3_output.resource.id,
                                         output_path='/bitmovin-python/StreamTests/' + str(uuid.uuid4()),
                                         acl=[acl_entry])

        return encoding_output

    def _get_sample_period_default(self):
        period = Period()
        return period

    def _get_special_period(self):
        period = self._get_sample_period_default()
        period.start = 1.33
        period.duration = 67.3
        return period

    def _get_sample_adaptationset(self):
        video_adaptationset = VideoAdaptationSet()
        return video_adaptationset

    def _get_sample_fmp4_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        fmp4_representation = FMP4Representation(type=FMP4RepresentationType.TEMPLATE,
                                                 encoding_id=encoding_id,
                                                 muxing_id=muxing_id,
                                                 segment_path='/path/to/segments/',
                                                 start_segment_number=1,
                                                 end_segment_number=2)

        return fmp4_representation

    def _get_sample_drm_fmp4_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        drm_id = self.sampleDrm.id
        fmp4_representation = DRMFMP4Representation(type=FMP4RepresentationType.TEMPLATE,
                                                    encoding_id=encoding_id,
                                                    muxing_id=muxing_id,
                                                    segment_path='/path/to/segments/',
                                                    start_segment_number=1,
                                                    end_segment_number=2,
                                                    drm_id=drm_id)

        return fmp4_representation

    def _get_sample_webm_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        webm_representation = WebMRepresentation(type=WebMRepresentationType.TEMPLATE,<commit_msg>Adding basic test case for representation with keyframes<commit_after>import unittest
import uuid
from bitmovin import Bitmovin, DashManifest, ACLEntry, ACLPermission, EncodingOutput, Period, VideoAdaptationSet, \
    AbstractAdaptationSet, FMP4Representation, FMP4RepresentationType, DRMFMP4Representation, Encoding, \
    Stream, StreamInput, MuxingStream, FMP4Muxing, MarlinDRM, AbstractFMP4Representation, WebMRepresentation, \
    WebMRepresentationType, DashMP4Representation
from tests.bitmovin import BitmovinTestCase


class RepresentationTests(BitmovinTestCase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()

    @classmethod
    def tearDownClass(cls):
        super().tearDownClass()

    def setUp(self):
        super().setUp()
        self.bitmovin = Bitmovin(self.api_key)
        self.assertIsNotNone(self.bitmovin)
        self.assertTrue(isinstance(self.bitmovin, Bitmovin))
        self.sampleEncoding = self._create_sample_encoding()  # type: Encoding
        self.sampleMuxing = self._create_sample_muxing()  # type: FMP4Muxing
        self.sampleDrm = self._create_sample_drm()  # type: MarlinDRM

    def tearDown(self):
        super().tearDown()

    def test_add_fmp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_fmp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_fmp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_fmp4_representations(sample_representation, representation_resource_response.resource)

    def test_add_fmp4_representation_with_keyframes(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_fmp4_representation_with_keyframes()
        representation_resource_response = self.bitmovin.manifests.DASH.add_fmp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_fmp4_representations(sample_representation, representation_resource_response.resource)

    def test_add_drm_fmp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_drm_fmp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_drm_fmp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_drm_fmp4_representations(sample_representation, representation_resource_response.resource)

    def test_add_webm_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_webm_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_webm_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_webm_representations(sample_representation, representation_resource_response.resource)

    def test_add_mp4_representation(self):
        sample_manifest = self._get_sample_manifest()
        manifest_resource_response = self.bitmovin.manifests.DASH.create(sample_manifest)
        self.assertIsNotNone(manifest_resource_response)
        self.assertIsNotNone(manifest_resource_response.resource)
        self.assertIsNotNone(manifest_resource_response.resource.id)
        self._compare_manifests(sample_manifest, manifest_resource_response.resource)
        sample_period = self._get_sample_period_default()
        period_resource_response = self.bitmovin.manifests.DASH.add_period(
            object_=sample_period, manifest_id=manifest_resource_response.resource.id)
        self.assertIsNotNone(period_resource_response)
        self.assertIsNotNone(period_resource_response.resource)
        self.assertIsNotNone(period_resource_response.resource.id)
        self._compare_periods(sample_period, period_resource_response.resource)
        sample_adaptationset = self._get_sample_adaptationset()
        adaptationset_resource_response = self.bitmovin.manifests.DASH.add_video_adaptation_set(
            object_=sample_adaptationset, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id
        )
        self.assertIsNotNone(adaptationset_resource_response)
        self.assertIsNotNone(adaptationset_resource_response.resource)
        self.assertIsNotNone(adaptationset_resource_response.resource.id)
        self._compare_video_adaptationsets(sample_adaptationset, adaptationset_resource_response.resource)
        sample_representation = self._get_sample_mp4_representation()
        representation_resource_response = self.bitmovin.manifests.DASH.add_mp4_representation(
            object_=sample_representation, manifest_id=manifest_resource_response.resource.id,
            period_id=period_resource_response.resource.id, adaptationset_id=adaptationset_resource_response.resource.id
        )
        self.assertIsNotNone(representation_resource_response)
        self.assertIsNotNone(representation_resource_response.resource)
        self.assertIsNotNone(representation_resource_response.resource.id)
        self._compare_mp4_representations(sample_representation, representation_resource_response.resource)

    def _compare_manifests(self, first: DashManifest, second: DashManifest):
        self.assertEqual(first.manifestName, second.manifestName)
        self.assertEqual(first.description, second.description)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        return True

    def _compare_periods(self, first: Period, second: Period):
        self.assertEqual(first.start, second.start)
        self.assertEqual(first.duration, second.duration)
        return True

    def _compare_adaptationsets(self, first: AbstractAdaptationSet, second: AbstractAdaptationSet):
        return True

    def _compare_video_adaptationsets(self, first: VideoAdaptationSet, second: VideoAdaptationSet):
        self._compare_adaptationsets(first, second)
        return True

    def _compare_fmp4_representations(self, first: AbstractFMP4Representation, second: AbstractFMP4Representation):
        self.assertEqual(first.type, second.type)
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.segmentPath, second.segmentPath)
        self.assertEqual(first.startSegmentNumber, second.startSegmentNumber)
        self.assertEqual(first.endSegmentNumber, second.endSegmentNumber)
        self.assertEqual(first.startKeyframeId, second.startKeyframeId)
        self.assertEqual(first.endKeyframeId, second.endKeyframeId)
        return True

    def _compare_drm_fmp4_representations(self, first: DRMFMP4Representation, second: DRMFMP4Representation):
        self._compare_fmp4_representations(first, second)
        self.assertEqual(first.drmId, second.drmId)
        return True

    def _compare_webm_representations(self, first: WebMRepresentation, second: WebMRepresentation):
        self.assertEqual(first.type, second.type)
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.segmentPath, second.segmentPath)
        self.assertEqual(first.startSegmentNumber, second.startSegmentNumber)
        return True
    
    def _compare_mp4_representations(self, first: DashMP4Representation, second: DashMP4Representation):
        self.assertEqual(first.encodingId, second.encodingId)
        self.assertEqual(first.muxingId, second.muxingId)
        self.assertEqual(first.filePath, second.filePath)
        return True

    def _compare_encodings(self, first: Encoding, second: Encoding):
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        self.assertEqual(first.encoderVersion, second.encoderVersion)
        self.assertEqual(first.cloudRegion, second.cloudRegion)
        return True

    def _compare_muxings(self, first: FMP4Muxing, second: FMP4Muxing):
        self.assertEqual(first.initSegmentName, second.initSegmentName)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.segmentLength, second.segmentLength)
        self.assertEqual(first.segmentNaming, second.segmentNaming)
        self.assertEqual(first.name, second.name)
        self.assertEqual(second.description, second.description)
        return True

    def _compare_drms(self, first: MarlinDRM, second: MarlinDRM):
        self.assertEqual(first.kid, second.kid)
        self.assertEqual(first.key, second.key)
        self.assertEqual(len(first.outputs), len(second.outputs))
        self.assertEqual(first.name, second.name)
        self.assertEqual(first.description, second.description)
        return True

    def _get_sample_manifest(self):
        encoding_output = self._get_sample_encoding_output()
        manifest = DashManifest(manifest_name='bitmovin-python_Sample_DASH_Manifest.mpd', outputs=[encoding_output],
                                name='Sample DASH Manifest')

        self.assertIsNotNone(manifest)
        self.assertIsNotNone(manifest.manifestName)
        self.assertIsNotNone(manifest.outputs)
        return manifest

    def _get_sample_encoding_output(self):
        acl_entry = ACLEntry(scope='string', permission=ACLPermission.PUBLIC_READ)

        sample_output = self.utils.get_sample_s3_output()
        s3_output = self.bitmovin.outputs.S3.create(sample_output)
        encoding_output = EncodingOutput(output_id=s3_output.resource.id,
                                         output_path='/bitmovin-python/StreamTests/' + str(uuid.uuid4()),
                                         acl=[acl_entry])

        return encoding_output

    def _get_sample_period_default(self):
        period = Period()
        return period

    def _get_special_period(self):
        period = self._get_sample_period_default()
        period.start = 1.33
        period.duration = 67.3
        return period

    def _get_sample_adaptationset(self):
        video_adaptationset = VideoAdaptationSet()
        return video_adaptationset

    def _get_sample_fmp4_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        fmp4_representation = FMP4Representation(type=FMP4RepresentationType.TEMPLATE,
                                                 encoding_id=encoding_id,
                                                 muxing_id=muxing_id,
                                                 segment_path='/path/to/segments/',
                                                 start_segment_number=1,
                                                 end_segment_number=2)

        return fmp4_representation

    def _get_sample_fmp4_representation_with_keyframes(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        fmp4_representation = FMP4Representation(type=FMP4RepresentationType.TEMPLATE,
                                                 encoding_id=encoding_id,
                                                 muxing_id=muxing_id,
                                                 segment_path='/path/to/segments/',
                                                 start_keyframe_id='345678987654345678',
                                                 end_keyframe_id='3453453454')

        return fmp4_representation


    def _get_sample_drm_fmp4_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        drm_id = self.sampleDrm.id
        fmp4_representation = DRMFMP4Representation(type=FMP4RepresentationType.TEMPLATE,
                                                    encoding_id=encoding_id,
                                                    muxing_id=muxing_id,
                                                    segment_path='/path/to/segments/',
                                                    start_segment_number=1,
                                                    end_segment_number=2,
                                                    drm_id=drm_id)

        return fmp4_representation

    def _get_sample_webm_representation(self):
        encoding_id = self.sampleEncoding.id
        muxing_id = self.sampleMuxing.id
        webm_representation = WebMRepresentation(type=WebMRepresentationType.TEMPLATE,
{'fraction_non_alphanumeric': 0.06848686164897783, 'fraction_numerical': 0.0040238731804801645, 'mean_word_length': 3.590306185694806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '256551', 'n_tokens_mistral': 10354, 'n_tokens_neox': 9862, 'n_words': 1098}