예제 #1
0
    def test_author_get_display_name_with_type_translation(self):
        """
        Test that the display name of an author with a type is correct (Translation)
        """
        # GIVEN: An author
        author = Author()
        author.display_name = "John Doe"

        # WHEN: We call the get_display_name() function
        display_name = author.get_display_name(AuthorType.Translation)

        # THEN: It should return the name with the type in brackets
        self.assertEqual("John Doe (Translation)", display_name)
예제 #2
0
    def test_author_get_display_name(self):
        """
        Test that the display name of an author is correct
        """
        # GIVEN: An author
        author = Author()
        author.display_name = "John Doe"

        # WHEN: We call the get_display_name() function
        display_name = author.get_display_name()

        # THEN: It should return only the name
        self.assertEqual("John Doe", display_name)
예제 #3
0
파일: test_db.py 프로젝트: ipic/projecao
    def test_author_get_display_name_with_type_words(self):
        """
        Test that the display name of an author with a type is correct (Words)
        """
        # GIVEN: An author
        author = Author()
        author.display_name = "John Doe"

        # WHEN: We call the get_display_name() function
        display_name = author.get_display_name(AuthorType.Words)

        # THEN: It should return the name with the type in brackets
        assert "John Doe (Words)" == display_name
예제 #4
0
    def test_remove_author(self):
        """
        Test removing an author from a song
        """
        # GIVEN: A song with an author
        song = Song()
        song.authors_songs = []
        author = Author()
        song.add_author(author)

        # WHEN: We remove the author
        song.remove_author(author)

        # THEN: It should have been removed
        self.assertEqual(0, len(song.authors_songs))
예제 #5
0
    def test_remove_author_with_type(self):
        """
        Test removing an author with a type specified from a song
        """
        # GIVEN: A song with two authors
        song = Song()
        song.authors_songs = []
        author = Author()
        song.add_author(author)
        song.add_author(author, AuthorType.Translation)

        # WHEN: We remove the author with a certain type
        song.remove_author(author, AuthorType.Translation)

        # THEN: It should have been removed and the other author should still be there
        self.assertEqual(1, len(song.authors_songs))
        self.assertEqual(None, song.authors_songs[0].author_type)
예제 #6
0
    def test_add_author_with_type(self):
        """
        Test adding an author with a type specified to a song
        """
        # GIVEN: A song and an author
        song = Song()
        song.authors_songs = []
        author = Author()
        author.first_name = "Max"
        author.last_name = "Mustermann"

        # WHEN: We add an author to the song
        song.add_author(author, AuthorType.Words)

        # THEN: The author should have been added with author_type=None
        self.assertEqual(1, len(song.authors_songs))
        self.assertEqual("Max", song.authors_songs[0].author.first_name)
        self.assertEqual("Mustermann", song.authors_songs[0].author.last_name)
        self.assertEqual(AuthorType.Words, song.authors_songs[0].author_type)
예제 #7
0
파일: test_db.py 프로젝트: ipic/projecao
    def test_add_author(self):
        """
        Test adding an author to a song
        """
        # GIVEN: A song and an author
        song = Song()
        song.authors_songs = []
        author = Author()
        author.first_name = "Max"
        author.last_name = "Mustermann"

        # WHEN: We add an author to the song
        song.add_author(author)

        # THEN: The author should have been added with author_type=None
        assert 1 == len(song.authors_songs)
        assert "Max" == song.authors_songs[0].author.first_name
        assert "Mustermann" == song.authors_songs[0].author.last_name
        assert song.authors_songs[0].author_type is None