def test__add_default_parameters(self): testpipeline = FFmpegPipeline(1, { "template": None, "type": "ffmpeg" }, "models") testpipeline.config = { "parameters": { "param1": { "default": 1234 }, "param2": {}, "param3": { "default": 1234 } } } testpipeline.request = {"parameters": {"param3": {}, "param4": {}}} expected_result = { "parameters": { 'param3': {}, 'param4': {}, 'param1': 1234 } } testpipeline._add_default_parameters() self.assertEqual(testpipeline.request, expected_result)
def test__add_tags_empty(self): testpipeline = FFmpegPipeline(1, {"template": None, "type": "ffmpeg"}, "models") testpipeline.request = {} iemetadata_args = [] testpipeline._add_tags(iemetadata_args) self.assertEqual(iemetadata_args, [])
def test__add_tags_error(self, mock_log_error): testpipeline = FFmpegPipeline(1, { "template": None, "type": "ffmpeg" }, "models") testpipeline.request = {"tags": {"tag1": "value1", "tag2": "value2"}} expected_iemetadata_args = [ '-custom_tag', 'tag1:value1,', '-custom_tag', 'tag2:value2' ] testpipeline._add_tags(None) mock_log_error.assert_called_with("Error adding tags")
def test__add_tags(self): testpipeline = FFmpegPipeline(1, { "template": None, "type": "ffmpeg" }, "models") testpipeline.request = {"tags": {"tag1": "value1", "tag2": "value2"}} iemetadata_args = [] expected_iemetadata_args = [ '-custom_tag', 'tag1:value1,', '-custom_tag', 'tag2:value2' ] testpipeline._add_tags(iemetadata_args) self.assertEqual(iemetadata_args, expected_iemetadata_args)
def test__add_tags(self): testpipeline = FFmpegPipeline(1, { "template": None, "type": "ffmpeg" }, "models") testpipeline.request = {"tags": {"tag1": "value1", "tag2": "value2"}} iemetadata_args = [] testpipeline._add_tags(iemetadata_args) self.assertEqual(str(iemetadata_args).count('-custom_tag'), 2) self.assertRegex(str(iemetadata_args), "tag.:value.,") self.assertRegex(str(iemetadata_args), "tag.:value.\'") self.assertIn('tag1:value1', str(iemetadata_args)) self.assertIn('tag2:value2', str(iemetadata_args))
def test_params(self): testpipeline = FFmpegPipeline(1, {"template": None, "type": "ffmpeg"}, "models") testpipeline.request = { "models": "dummymodels" } testpipeline._ffmpeg_launch_string = "dummylaunchstring" expected_result = { "id": 1, "request": {}, "type": "ffmpeg", "launch_command": "dummylaunchstring" } result = testpipeline.params() self.assertEqual(result, expected_result)