Exemplo n.º 1
0
    def test_load_templates_custom_names_success(self):
        """Test to load templates using existing names

        In that case, the templates come from the custom directory and have the
        correct name.
        """
        # create object
        text_generator = TextGenerator(
            {
                "directory": get_file("tests.resources", ""),
                "idle_template_name": "song.ass",
                "transition_template_name": "song.ass",
            }
        )

        # pre assert there are no templates
        self.assertIsNone(text_generator.idle_template)
        self.assertIsNone(text_generator.transition_template)

        # call the method
        text_generator.load_templates()

        # assert there are templates defined
        self.assertEqual(
            text_generator.idle_template.filename,
            get_file("tests.resources", "song.ass"),
        )
        self.assertEqual(
            text_generator.transition_template.filename,
            get_file("tests.resources", "song.ass"),
        )
Exemplo n.º 2
0
    def test_load_templates_custom_names_fail(self):
        """Test to load templates using names that do not exist

        In that case, the templates come from the custom directory and have
        the default name.
        """
        # create object
        text_generator = TextGenerator(
            {
                "directory": get_file("tests.resources", ""),
                "idle_template_name": "nothing",
                "transition_template_name": "nothing",
            }
        )

        # pre assert there are no templates
        self.assertIsNone(text_generator.idle_template)
        self.assertIsNone(text_generator.transition_template)

        # call the method
        text_generator.load_templates()

        # assert there are templates defined
        self.assertEqual(
            text_generator.idle_template.filename,
            get_file("tests.resources", IDLE_TEMPLATE_NAME),
        )
        self.assertEqual(
            text_generator.transition_template.filename,
            get_file("tests.resources", TRANSITION_TEMPLATE_NAME),
        )
Exemplo n.º 3
0
    def setUp(self):
        # create info dictionary
        self.idle_info = {"notes": ["VLC 0.0.0", "Dakara player 0.0.0"]}

        # create playlist entry
        self.playlist_entry = {
            "song": {
                "title": "Song title",
                "artists": [{"name": "Artist name"}],
                "works": [
                    {
                        "work": {
                            "title": "Work title",
                            "subtitle": "Subtitle of the work",
                            "work_type": {
                                "name": "Work type name",
                                "icon_name": "music",
                            },
                        },
                        "link_type": "OP",
                        "link_type_number": 1,
                        "episodes": "1, 2, 3",
                    }
                ],
                "file_path": "path/of/the/file",
            },
            "owner": {"username": "******"},
            "date_created": "1970-01-01T00:00:00.00",
        }

        # create idle text content
        self.idle_text_path = get_file("tests.resources", "idle.ass")

        # create transition text content
        self.transition_text_path = get_file("tests.resources", "transition.ass")

        # create text generator object
        self.text_generator = TextGenerator({})
        self.text_generator.load()
Exemplo n.º 4
0
    def test_load_templates_custom_directory_success(self):
        """Test to load custom templates using an existing directory

        In that case, the templates come from this directory.
        """
        # create object
        text_generator = TextGenerator({"directory": get_file("tests.resources", "")})

        # pre assert there are no templates
        self.assertIsNone(text_generator.idle_template)
        self.assertIsNone(text_generator.transition_template)

        # call the method
        text_generator.load_templates()

        # assert there are templates defined
        self.assertEqual(
            text_generator.idle_template.filename,
            get_file("tests.resources", IDLE_TEMPLATE_NAME),
        )
        self.assertEqual(
            text_generator.transition_template.filename,
            get_file("tests.resources", TRANSITION_TEMPLATE_NAME),
        )
Exemplo n.º 5
0
 def load_icon_map(self):
     """Load the icon map
     """
     icon_map_path = get_file("dakara_player_vlc.resources", ICON_MAP_FILE)
     with icon_map_path.open() as file:
         self.icon_map = json.load(file)