Exemple #1
0
    def testGenerateFileName(self):
        #FIXME: More than one Style, different file suffixes, arcs.
        # generateFileName(Style=None)

        correctShow1 = Show('Black Books', '30', 'imdbtvbackend', 'tt0262150')
        correctShow1.addEpisode(
            Episode('2', "A test's test' & a test / # a test",
                    '6 October 2000', 'none'), Season('1'))

        correctShow2 = Show('Spaced', '60', 'imdbtvbackend', 'tt0187664')
        correctShow2.addEpisode(
            Episode('3', "A test's test' & a test / # a test", '9 March 2001',
                    'none'), Season('2'))

        correctShow3 = Show('C.S.I', '60', 'imdbtvbackend', 'tt0247082')
        correctShow3.addEpisode(
            Episode('13', "Identity Crisis / # 4587", '17 January 2002',
                    'none'), Season('2'))

        self.FN = FileName('', self.database)
        self.FN.fileSuffix = '.avi'

        fileName1 = self.FN.generateFileName(
            correctShow1, self.Tools.filetypesXML, 'ext3',
            '%show.S%seasonE%episode.%title.%arc.%airdate')
        fileName2 = self.FN.generateFileName(
            correctShow2, self.Tools.filetypesXML, 'ntfs',
            '%show.S%seasonE%episode.%title.%arc.%airdate')
        fileName3 = self.FN.generateFileName(
            correctShow3, self.Tools.filetypesXML, 'ext3',
            '%show.S%seasonE%episode.%title.%arc.%airdate')

        assert fileName1 == "Black Books.S01E02.A test's test' & a test or # a test.none.6 October 2000.avi"
        assert fileName2 == "Spaced.S02E03.A tests test and a test or No. a test.none.9 March 2001.avi"
        assert fileName3 == "C.S.I.S02E13.Identity Crisis or # 4587.none.17 January 2002.avi"
Exemple #2
0
    def testGetShowDetails(self):

        testShows = [
            fn.getShowDetails(self.Tools.filetypesXML, fn.getMatchingShows())
            for fn in self.filenames
        ]

        assert [len(ts.seasons) for ts in testShows] == [1, 1, 1, 1, 1]
        assert [len(ts.seasons[0].episodes)
                for ts in testShows] == [1, 1, 1, 1, 1]

        correctShow1 = Show('Black Books', '30', 'imdbtvbackend', 'tt0262150')
        correctShow1.addEpisode(
            Episode('2', "Manny's First Day", '6 October 2000', 'none'),
            Season('1'))

        correctShow2 = Show('Spaced', '60', 'imdbtvbackend', 'tt0187664')
        correctShow2.addEpisode(Episode('3', 'Mettle', '9 March 2001', 'none'),
                                Season('2'))

        correctShow3 = Show('C.S.I', '60', 'imdbtvbackend', 'tt0247082')
        correctShow3.addEpisode(
            Episode('13', 'Identity Crisis', '17 January 2002', 'none'),
            Season('2'))

        def compareShows(show, other):
            if show.name != other.name or show.duration != other.duration or show.backend != other.backend or show.url != other.url:
                assert False
            elif show.seasons[0].name != other.seasons[0].name:
                assert False
            elif show.seasons[0].episodes[0].name != other.seasons[0].episodes[
                    0].name or show.seasons[0].episodes[
                        0].title != other.seasons[0].episodes[
                            0].title or show.seasons[0].episodes[
                                0].airdate != other.seasons[0].episodes[
                                    0].airdate or show.seasons[0].episodes[
                                        0].arc != other.seasons[0].episodes[
                                            0].arc:
                assert False
            else:
                return True

        assert compareShows(testShows[0], correctShow1)
        assert compareShows(testShows[1], correctShow2)
        assert compareShows(testShows[2], correctShow3)
Exemple #3
0
 def testCompareSeasons(self):
     
     Episode1 = Episode( "2", "What A Title", "6 November, 2008" )
     Episode2 = Episode( "333", "For A TV Show", "18 November, 2008" )
     Episode3 = Episode( "4", "What A Title", "6 November, 2008")
     Episode4 = Episode( "2", "What A Title", "6 November, 2008" )
     Episode5 = Episode( "333", "For A TV Show", "18 November, 2008" )
     Episode6 = Episode( "4", "What A Title", "6 November, 2008")
     
     Season1 = Season('1')
     Season2 = Season('2')
     
     Season1.addEpisode( Episode1 )
     Season1.addEpisode( Episode2 )
     Season1.addEpisode( Episode3 )
     Season2.addEpisode( Episode4 )
     Season2.addEpisode( Episode5 )
     Season2.addEpisode( Episode6 )
     
     assert self.BaIf1.compareSeasons( Season1, Season2 ).name == "1"
     assert self.BaIf1.compareSeasons( Season1, Season2 ).name == "1"
Exemple #4
0
 def testCompareDetails(self):
     
     Episode1 = Episode( "2", "What A Title", "6 November, 2008" )
     Episode2 = Episode( "333", "For A TV Show", "18 November, 2008" )
     Episode3 = Episode( "4", "What A Title", "6 November, 2008")
     Episode4 = Episode( "2", "What A Title", "6 November, 2008" )
     Episode5 = Episode( "333", "For A TV Show", "18 November, 2008" )
     Episode6 = Episode( "4", "What A Title", "6 November, 2008")
     
     Season1 = Season('1')
     Season2 = Season('2')
     
     Season1.addEpisode( Episode1 )
     Season1.addEpisode( Episode2 )
     Season1.addEpisode( Episode3 )
     Season2.addEpisode( Episode4 )
     Season2.addEpisode( Episode5 )
     Season2.addEpisode( Episode6 )
     
     Season3 = Season1
     Season4 = Season2
     
     Show1 = Show( "Test Show One", "60", "dummybackend", "dummyurlone" )
     Show2 = Show( "Test Show Two", "60", "dummybackend", "dummyurltwo" )
     
     Show3 = Show1
     
     Show1.addSeason(Season1)
     Show1.addSeason(Season2)
     Show2.addSeason(Season3)
     Show2.addSeason(Season4)
     
     s = self.BaIf1.compareDetails( Show1, Show2 )
     assert (s.name, s.duration, s.backend, s.url ) == ( "Test Show One", "60", "dummybackend", "dummyurlone" )
     s = self.BaIf1.compareDetails( Show1, Show2 )
     assert (s.name, s.duration, s.backend, s.url ) == ( "Test Show One", "60", "dummybackend", "dummyurlone" )
Exemple #5
0
    def setUp(self):
        self.Tools = Tools()
        self.Tools.createRootDir()
        self.Tools.createTempFiles()
        self.Tools.createDatabaseFiles()
        self.Tools.createFilesystemXML()

        self.database = Database(self.Tools.databaseDir)
        self.database.loadDB()

        smallville = Show('Smallville', '60', 'dummy', 'dummy')
        smallville.addAlias(Alias('smallville'))
        smallville.addEpisode(Episode('10', 'Bizarro', 'dummy'), Season('7'))
        self.database.addShow(smallville)

        self.files = [
            'blackbooks.s01e02.avi', 'spaced.2x03.avi', 'csi.s02E13.avi',
            'black books - 03x02 - Six of One.avi',
            'Smallville.S07E10.HDTV.XviD-XOR.avi'
        ]
        self.filenames = [
            FileName(files, self.database) for files in self.files
        ]
Exemple #6
0
    def testUpdateDatabase(self):

        assert os.path.exists(self.Tools.databaseDir) == True

        DB2 = []
        for filename in self.Tools.databaseFiles.values():
            testfile = open(os.path.join(self.Tools.databaseDir, filename),
                            "r")
            content = testfile.read()
            testfile.close()
            DB2.append((content, filename))

        assert DB2 == [
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="60" name="Spaced" url="tt0187664"/>\n  <aliases>\n    <alias value="spaced"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="24 September 1999" arc="none" number="1" title="Beginnings"/>\n    <episode airdate="1 October 1999" arc="none" number="2" title="Gatherings"/>\n    <episode airdate="8 October 1999" arc="none" number="3" title="Art"/>\n    <episode airdate="15 October 1999" arc="none" number="4" title="Battles"/>\n    <episode airdate="22 October 1999" arc="none" number="5" title="Chaos"/>\n    <episode airdate="29 October 1999" arc="none" number="6" title="Epiphanies"/>\n    <episode airdate="5 November 1999" arc="none" number="7" title="Ends"/>\n  </season>\n  <season number="2">\n    <episode airdate="23 February 2001" arc="none" number="1" title="Back"/>\n    <episode airdate="2 March 2001" arc="none" number="2" title="Change"/>\n    <episode airdate="9 March 2001" arc="none" number="3" title="Mettle"/>\n    <episode airdate="23 March 2001" arc="none" number="4" title="Help"/>\n    <episode airdate="None" arc="none" number="5" title="Gone"/>\n    <episode airdate="6 April 2001" arc="none" number="6" title="Dissolution"/>\n    <episode airdate="13 April 2001" arc="none" number="7" title="Testkonflikt"/>\n  </season>\n</tvshow>',
             'spaced.show'),
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="30" name="Black Books" url="tt0262150"/>\n  <aliases>\n    <alias value="blackbooks"/>\n    <alias value="black books"/>\n    <alias value="black.books"/>\n    <alias value="bb"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="29 September 2000" arc="none" number="1" title="Cooking the Books"/>\n    <episode airdate="6 October 2000" arc="none" number="2" title="Manny\'s First Day"/>\n    <episode airdate="13 October 2000" arc="none" number="3" title="The Grapes of Wrath"/>\n    <episode airdate="20 October 2000" arc="none" number="4" title="The Blackout"/>\n    <episode airdate="27 October 2000" arc="none" number="5" title="The Big Lock-Out"/>\n    <episode airdate="3 November 2000" arc="none" number="6" title="He\'s Leaving Home"/>\n  </season>\n  <season number="2">\n    <episode airdate="1 March 2002" arc="none" number="1" title="The Entertainer"/>\n    <episode airdate="8 March 2002" arc="none" number="2" title="Fever"/>\n    <episode airdate="15 March 2002" arc="none" number="3" title="The Fixer"/>\n    <episode airdate="22 March 2002" arc="none" number="4" title="Blood"/>\n    <episode airdate="29 March 2002" arc="none" number="5" title="Hello Sun"/>\n    <episode airdate="5 April 2002" arc="none" number="6" title="A Nice Change"/>\n  </season>\n  <season number="3">\n    <episode airdate="11 March 2004" arc="none" number="1" title="Manny Come Home"/>\n    <episode airdate="18 March 2004" arc="none" number="2" title="Elephants and Hens"/>\n    <episode airdate="25 March 2004" arc="none" number="3" title="Moo-Ma and Moo-Pa"/>\n    <episode airdate="1 April 2004" arc="none" number="4" title="A Little Flutter"/>\n    <episode airdate="8 April 2004" arc="none" number="5" title="The Travel Writer"/>\n    <episode airdate="15 April 2004" arc="none" number="6" title="Party"/>\n  </season>\n</tvshow>\n',
             'blackbooks.show'),
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="60" name="C.S.I" url="tt0247082"/>\n  <aliases>\n    <alias value="csi"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="6 October 2000" arc="none" number="1" title="Pilot"/>\n    <episode airdate="13 October 2000" arc="none" number="2" title="Cool Change"/>\n    <episode airdate="20 October 2000" arc="none" number="3" title="Crate \'n\' Burial"/>\n    <episode airdate="27 October 2000" arc="none" number="4" title="Pledging Mr. Johnson"/>\n    <episode airdate="3 November 2000" arc="none" number="5" title="Friends &amp; Lovers"/>\n    <episode airdate="10 November 2000" arc="none" number="6" title="Who Are You?"/>\n    <episode airdate="17 November 2000" arc="none" number="7" title="Blood Drops"/>\n    <episode airdate="24 November 2000" arc="none" number="8" title="Anonymous"/>\n    <episode airdate="8 December 2000" arc="none" number="9" title="Unfriendly Skies"/>\n    <episode airdate="22 December 2000" arc="none" number="10" title="Sex, Lies and Larvae"/>\n    <episode airdate="12 January 2001" arc="none" number="11" title="I-15 Murders"/>\n    <episode airdate="1 February 2001" arc="none" number="12" title="Fahrenheit 932"/>\n    <episode airdate="8 February 2001" arc="none" number="13" title="Boom"/>\n    <episode airdate="15 February 2001" arc="none" number="14" title="To Halve and to Hold"/>\n    <episode airdate="22 February 2001" arc="none" number="15" title="Table Stakes"/>\n    <episode airdate="1 March 2001" arc="none" number="16" title="Too Tough to Die"/>\n    <episode airdate="8 March 2001" arc="none" number="17" title="Face Lift"/>\n    <episode airdate="29 March 2001" arc="none" number="18" title="$35K O.B.O."/>\n    <episode airdate="12 April 2001" arc="none" number="19" title="Gentle, Gentle"/>\n    <episode airdate="19 April 2001" arc="none" number="20" title="Sounds of Silence"/>\n    <episode airdate="26 April 2001" arc="none" number="21" title="Justice Is Served"/>\n    <episode airdate="10 May 2001" arc="none" number="22" title="Evaluation Day"/>\n    <episode airdate="17 May 2001" arc="none" number="23" title="The Strip Strangler"/>\n  </season>\n  <season number="2">\n    <episode airdate="27 September 2001" arc="none" number="1" title="Burked"/>\n    <episode airdate="4 October 2001" arc="none" number="2" title="Chaos Theory"/>\n    <episode airdate="11 October 2001" arc="none" number="3" title="Overload"/>\n    <episode airdate="18 October 2001" arc="none" number="4" title="Bully for You"/>\n    <episode airdate="25 October 2001" arc="none" number="5" title="Scuba Doobie-Doo"/>\n    <episode airdate="1 November 2001" arc="none" number="6" title="Alter Boys"/>\n    <episode airdate="8 November 2001" arc="none" number="7" title="Caged"/>\n    <episode airdate="15 November 2001" arc="none" number="8" title="Slaves of Las Vegas"/>\n    <episode airdate="22 November 2001" arc="none" number="9" title="And Then There Were None"/>\n    <episode airdate="6 December 2001" arc="none" number="10" title="Ellie"/>\n    <episode airdate="13 December 2001" arc="none" number="11" title="Organ Grinder"/>\n    <episode airdate="20 December 2001" arc="none" number="12" title="You\'ve Got Male"/>\n    <episode airdate="17 January 2002" arc="none" number="13" title="Identity Crisis"/>\n    <episode airdate="None" arc="none" number="14" title="The Finger"/>\n    <episode airdate="7 February 2002" arc="none" number="15" title="Burden of Proof"/>\n    <episode airdate="28 February 2002" arc="none" number="16" title="Primum Non Nocere"/>\n    <episode airdate="7 March 2002" arc="none" number="17" title="Felonious Monk"/>\n    <episode airdate="28 March 2002" arc="none" number="18" title="Chasing the Bus"/>\n    <episode airdate="4 April 2002" arc="none" number="19" title="Stalker"/>\n    <episode airdate="25 April 2002" arc="none" number="20" title="Cats in the Cradle..."/>\n    <episode airdate="2 May 2002" arc="none" number="21" title="Anatomy of a Lye"/>\n    <episode airdate="9 May 2002" arc="none" number="22" title="Cross-Jurisdictions"/>\n    <episode airdate="18 May 2002" arc="none" number="23" title="The Hunger Artist"/>\n  </season>\n</tvshow>\n',
             'csi.show')
        ]

        show1 = self.BaIf1.currentDB.getShow(
            Show('Spaced', '30', 'imdbtvbackend', 'tt000000'))
        show1.removeSeason(Season('1'))

        DB21 = []
        for filename in self.Tools.databaseFiles.values():
            testfile = open(os.path.join(self.Tools.databaseDir, filename),
                            "r")
            content = testfile.read()
            testfile.close()
            DB21.append((content, filename))

        assert DB21 == [
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="60" name="Spaced" url="tt0187664"/>\n  <aliases>\n    <alias value="spaced"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="24 September 1999" arc="none" number="1" title="Beginnings"/>\n    <episode airdate="1 October 1999" arc="none" number="2" title="Gatherings"/>\n    <episode airdate="8 October 1999" arc="none" number="3" title="Art"/>\n    <episode airdate="15 October 1999" arc="none" number="4" title="Battles"/>\n    <episode airdate="22 October 1999" arc="none" number="5" title="Chaos"/>\n    <episode airdate="29 October 1999" arc="none" number="6" title="Epiphanies"/>\n    <episode airdate="5 November 1999" arc="none" number="7" title="Ends"/>\n  </season>\n  <season number="2">\n    <episode airdate="23 February 2001" arc="none" number="1" title="Back"/>\n    <episode airdate="2 March 2001" arc="none" number="2" title="Change"/>\n    <episode airdate="9 March 2001" arc="none" number="3" title="Mettle"/>\n    <episode airdate="23 March 2001" arc="none" number="4" title="Help"/>\n    <episode airdate="None" arc="none" number="5" title="Gone"/>\n    <episode airdate="6 April 2001" arc="none" number="6" title="Dissolution"/>\n    <episode airdate="13 April 2001" arc="none" number="7" title="Testkonflikt"/>\n  </season>\n</tvshow>',
             'spaced.show'),
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="30" name="Black Books" url="tt0262150"/>\n  <aliases>\n    <alias value="blackbooks"/>\n    <alias value="black books"/>\n    <alias value="black.books"/>\n    <alias value="bb"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="29 September 2000" arc="none" number="1" title="Cooking the Books"/>\n    <episode airdate="6 October 2000" arc="none" number="2" title="Manny\'s First Day"/>\n    <episode airdate="13 October 2000" arc="none" number="3" title="The Grapes of Wrath"/>\n    <episode airdate="20 October 2000" arc="none" number="4" title="The Blackout"/>\n    <episode airdate="27 October 2000" arc="none" number="5" title="The Big Lock-Out"/>\n    <episode airdate="3 November 2000" arc="none" number="6" title="He\'s Leaving Home"/>\n  </season>\n  <season number="2">\n    <episode airdate="1 March 2002" arc="none" number="1" title="The Entertainer"/>\n    <episode airdate="8 March 2002" arc="none" number="2" title="Fever"/>\n    <episode airdate="15 March 2002" arc="none" number="3" title="The Fixer"/>\n    <episode airdate="22 March 2002" arc="none" number="4" title="Blood"/>\n    <episode airdate="29 March 2002" arc="none" number="5" title="Hello Sun"/>\n    <episode airdate="5 April 2002" arc="none" number="6" title="A Nice Change"/>\n  </season>\n  <season number="3">\n    <episode airdate="11 March 2004" arc="none" number="1" title="Manny Come Home"/>\n    <episode airdate="18 March 2004" arc="none" number="2" title="Elephants and Hens"/>\n    <episode airdate="25 March 2004" arc="none" number="3" title="Moo-Ma and Moo-Pa"/>\n    <episode airdate="1 April 2004" arc="none" number="4" title="A Little Flutter"/>\n    <episode airdate="8 April 2004" arc="none" number="5" title="The Travel Writer"/>\n    <episode airdate="15 April 2004" arc="none" number="6" title="Party"/>\n  </season>\n</tvshow>\n',
             'blackbooks.show'),
            ('<?xml version="1.0" encoding="UTF-8"?>\n<tvshow>\n  <showproperties backend="imdbtvbackend" duration="60" name="C.S.I" url="tt0247082"/>\n  <aliases>\n    <alias value="csi"/>\n  </aliases>\n  <season number="1">\n    <episode airdate="6 October 2000" arc="none" number="1" title="Pilot"/>\n    <episode airdate="13 October 2000" arc="none" number="2" title="Cool Change"/>\n    <episode airdate="20 October 2000" arc="none" number="3" title="Crate \'n\' Burial"/>\n    <episode airdate="27 October 2000" arc="none" number="4" title="Pledging Mr. Johnson"/>\n    <episode airdate="3 November 2000" arc="none" number="5" title="Friends &amp; Lovers"/>\n    <episode airdate="10 November 2000" arc="none" number="6" title="Who Are You?"/>\n    <episode airdate="17 November 2000" arc="none" number="7" title="Blood Drops"/>\n    <episode airdate="24 November 2000" arc="none" number="8" title="Anonymous"/>\n    <episode airdate="8 December 2000" arc="none" number="9" title="Unfriendly Skies"/>\n    <episode airdate="22 December 2000" arc="none" number="10" title="Sex, Lies and Larvae"/>\n    <episode airdate="12 January 2001" arc="none" number="11" title="I-15 Murders"/>\n    <episode airdate="1 February 2001" arc="none" number="12" title="Fahrenheit 932"/>\n    <episode airdate="8 February 2001" arc="none" number="13" title="Boom"/>\n    <episode airdate="15 February 2001" arc="none" number="14" title="To Halve and to Hold"/>\n    <episode airdate="22 February 2001" arc="none" number="15" title="Table Stakes"/>\n    <episode airdate="1 March 2001" arc="none" number="16" title="Too Tough to Die"/>\n    <episode airdate="8 March 2001" arc="none" number="17" title="Face Lift"/>\n    <episode airdate="29 March 2001" arc="none" number="18" title="$35K O.B.O."/>\n    <episode airdate="12 April 2001" arc="none" number="19" title="Gentle, Gentle"/>\n    <episode airdate="19 April 2001" arc="none" number="20" title="Sounds of Silence"/>\n    <episode airdate="26 April 2001" arc="none" number="21" title="Justice Is Served"/>\n    <episode airdate="10 May 2001" arc="none" number="22" title="Evaluation Day"/>\n    <episode airdate="17 May 2001" arc="none" number="23" title="The Strip Strangler"/>\n  </season>\n  <season number="2">\n    <episode airdate="27 September 2001" arc="none" number="1" title="Burked"/>\n    <episode airdate="4 October 2001" arc="none" number="2" title="Chaos Theory"/>\n    <episode airdate="11 October 2001" arc="none" number="3" title="Overload"/>\n    <episode airdate="18 October 2001" arc="none" number="4" title="Bully for You"/>\n    <episode airdate="25 October 2001" arc="none" number="5" title="Scuba Doobie-Doo"/>\n    <episode airdate="1 November 2001" arc="none" number="6" title="Alter Boys"/>\n    <episode airdate="8 November 2001" arc="none" number="7" title="Caged"/>\n    <episode airdate="15 November 2001" arc="none" number="8" title="Slaves of Las Vegas"/>\n    <episode airdate="22 November 2001" arc="none" number="9" title="And Then There Were None"/>\n    <episode airdate="6 December 2001" arc="none" number="10" title="Ellie"/>\n    <episode airdate="13 December 2001" arc="none" number="11" title="Organ Grinder"/>\n    <episode airdate="20 December 2001" arc="none" number="12" title="You\'ve Got Male"/>\n    <episode airdate="17 January 2002" arc="none" number="13" title="Identity Crisis"/>\n    <episode airdate="None" arc="none" number="14" title="The Finger"/>\n    <episode airdate="7 February 2002" arc="none" number="15" title="Burden of Proof"/>\n    <episode airdate="28 February 2002" arc="none" number="16" title="Primum Non Nocere"/>\n    <episode airdate="7 March 2002" arc="none" number="17" title="Felonious Monk"/>\n    <episode airdate="28 March 2002" arc="none" number="18" title="Chasing the Bus"/>\n    <episode airdate="4 April 2002" arc="none" number="19" title="Stalker"/>\n    <episode airdate="25 April 2002" arc="none" number="20" title="Cats in the Cradle..."/>\n    <episode airdate="2 May 2002" arc="none" number="21" title="Anatomy of a Lye"/>\n    <episode airdate="9 May 2002" arc="none" number="22" title="Cross-Jurisdictions"/>\n    <episode airdate="18 May 2002" arc="none" number="23" title="The Hunger Artist"/>\n  </season>\n</tvshow>\n',
             'csi.show')
        ]

        self.BaIf1.currentDB.write()

        DB211 = []
        for filename in self.Tools.databaseFiles.values():
            testfile = open(os.path.join(self.Tools.databaseDir, filename),
                            "r")
            content = testfile.read()
            testfile.close()
            DB211.append((content, filename))

        assert DB211 == [
            ('<tvshow><showproperties backend="imdbtvbackend" duration="60" name="Spaced" url="tt0187664" /><aliases><alias value="spaced" /></aliases><season number="2"><episode airdate="23 February 2001" arc="none" number="1" title="Back" /><episode airdate="2 March 2001" arc="none" number="2" title="Change" /><episode airdate="9 March 2001" arc="none" number="3" title="Mettle" /><episode airdate="23 March 2001" arc="none" number="4" title="Help" /><episode airdate="None" arc="none" number="5" title="Gone" /><episode airdate="6 April 2001" arc="none" number="6" title="Dissolution" /><episode airdate="13 April 2001" arc="none" number="7" title="Testkonflikt" /></season></tvshow>',
             'spaced.show'),
            ('<tvshow><showproperties backend="imdbtvbackend" duration="30" name="Black Books" url="tt0262150" /><aliases><alias value="blackbooks" /><alias value="black books" /><alias value="black.books" /><alias value="bb" /></aliases><season number="1"><episode airdate="29 September 2000" arc="none" number="1" title="Cooking the Books" /><episode airdate="6 October 2000" arc="none" number="2" title="Manny&apos;s First Day" /><episode airdate="13 October 2000" arc="none" number="3" title="The Grapes of Wrath" /><episode airdate="20 October 2000" arc="none" number="4" title="The Blackout" /><episode airdate="27 October 2000" arc="none" number="5" title="The Big Lock-Out" /><episode airdate="3 November 2000" arc="none" number="6" title="He&apos;s Leaving Home" /></season><season number="2"><episode airdate="1 March 2002" arc="none" number="1" title="The Entertainer" /><episode airdate="8 March 2002" arc="none" number="2" title="Fever" /><episode airdate="15 March 2002" arc="none" number="3" title="The Fixer" /><episode airdate="22 March 2002" arc="none" number="4" title="Blood" /><episode airdate="29 March 2002" arc="none" number="5" title="Hello Sun" /><episode airdate="5 April 2002" arc="none" number="6" title="A Nice Change" /></season><season number="3"><episode airdate="11 March 2004" arc="none" number="1" title="Manny Come Home" /><episode airdate="18 March 2004" arc="none" number="2" title="Elephants and Hens" /><episode airdate="25 March 2004" arc="none" number="3" title="Moo-Ma and Moo-Pa" /><episode airdate="1 April 2004" arc="none" number="4" title="A Little Flutter" /><episode airdate="8 April 2004" arc="none" number="5" title="The Travel Writer" /><episode airdate="15 April 2004" arc="none" number="6" title="Party" /></season></tvshow>',
             'blackbooks.show'),
            ('<tvshow><showproperties backend="imdbtvbackend" duration="60" name="C.S.I" url="tt0247082" /><aliases><alias value="csi" /></aliases><season number="1"><episode airdate="6 October 2000" arc="none" number="1" title="Pilot" /><episode airdate="13 October 2000" arc="none" number="2" title="Cool Change" /><episode airdate="20 October 2000" arc="none" number="3" title="Crate &apos;n&apos; Burial" /><episode airdate="27 October 2000" arc="none" number="4" title="Pledging Mr. Johnson" /><episode airdate="3 November 2000" arc="none" number="5" title="Friends &amp; Lovers" /><episode airdate="10 November 2000" arc="none" number="6" title="Who Are You?" /><episode airdate="17 November 2000" arc="none" number="7" title="Blood Drops" /><episode airdate="24 November 2000" arc="none" number="8" title="Anonymous" /><episode airdate="8 December 2000" arc="none" number="9" title="Unfriendly Skies" /><episode airdate="22 December 2000" arc="none" number="10" title="Sex, Lies and Larvae" /><episode airdate="12 January 2001" arc="none" number="11" title="I-15 Murders" /><episode airdate="1 February 2001" arc="none" number="12" title="Fahrenheit 932" /><episode airdate="8 February 2001" arc="none" number="13" title="Boom" /><episode airdate="15 February 2001" arc="none" number="14" title="To Halve and to Hold" /><episode airdate="22 February 2001" arc="none" number="15" title="Table Stakes" /><episode airdate="1 March 2001" arc="none" number="16" title="Too Tough to Die" /><episode airdate="8 March 2001" arc="none" number="17" title="Face Lift" /><episode airdate="29 March 2001" arc="none" number="18" title="$35K O.B.O." /><episode airdate="12 April 2001" arc="none" number="19" title="Gentle, Gentle" /><episode airdate="19 April 2001" arc="none" number="20" title="Sounds of Silence" /><episode airdate="26 April 2001" arc="none" number="21" title="Justice Is Served" /><episode airdate="10 May 2001" arc="none" number="22" title="Evaluation Day" /><episode airdate="17 May 2001" arc="none" number="23" title="The Strip Strangler" /></season><season number="2"><episode airdate="27 September 2001" arc="none" number="1" title="Burked" /><episode airdate="4 October 2001" arc="none" number="2" title="Chaos Theory" /><episode airdate="11 October 2001" arc="none" number="3" title="Overload" /><episode airdate="18 October 2001" arc="none" number="4" title="Bully for You" /><episode airdate="25 October 2001" arc="none" number="5" title="Scuba Doobie-Doo" /><episode airdate="1 November 2001" arc="none" number="6" title="Alter Boys" /><episode airdate="8 November 2001" arc="none" number="7" title="Caged" /><episode airdate="15 November 2001" arc="none" number="8" title="Slaves of Las Vegas" /><episode airdate="22 November 2001" arc="none" number="9" title="And Then There Were None" /><episode airdate="6 December 2001" arc="none" number="10" title="Ellie" /><episode airdate="13 December 2001" arc="none" number="11" title="Organ Grinder" /><episode airdate="20 December 2001" arc="none" number="12" title="You&apos;ve Got Male" /><episode airdate="17 January 2002" arc="none" number="13" title="Identity Crisis" /><episode airdate="None" arc="none" number="14" title="The Finger" /><episode airdate="7 February 2002" arc="none" number="15" title="Burden of Proof" /><episode airdate="28 February 2002" arc="none" number="16" title="Primum Non Nocere" /><episode airdate="7 March 2002" arc="none" number="17" title="Felonious Monk" /><episode airdate="28 March 2002" arc="none" number="18" title="Chasing the Bus" /><episode airdate="4 April 2002" arc="none" number="19" title="Stalker" /><episode airdate="25 April 2002" arc="none" number="20" title="Cats in the Cradle..." /><episode airdate="2 May 2002" arc="none" number="21" title="Anatomy of a Lye" /><episode airdate="9 May 2002" arc="none" number="22" title="Cross-Jurisdictions" /><episode airdate="18 May 2002" arc="none" number="23" title="The Hunger Artist" /></season></tvshow>',
             'csi.show')
        ]

        self.BaIf1.currentDB.removeShow(
            Show('C.S.I', '60', 'imdbtvbackend', 'tt000000'))
        self.BaIf1.currentDB.delete(
            Show('C.S.I', '60', 'imdbtvbackend', 'tt000000'))

        #Tools.databaseFiles = {key : value for key, value in self.Tools.databaseFiles.items() if value is not 'csi.show'}

        temp_dict = dict()
        for key, value in self.Tools.databaseFiles.iteritems():
            if value != 'csi.show':
                temp_dict[key] = value

        self.Tools.databaseFiles = temp_dict

        DB22 = []
        for filename in self.Tools.databaseFiles.values():
            testfile = open(os.path.join(self.Tools.databaseDir, filename),
                            "r")
            content = testfile.read()
            testfile.close()
            DB22.append((content, filename))

        assert DB22 == [
            ('<tvshow><showproperties backend="imdbtvbackend" duration="60" name="Spaced" url="tt0187664" /><aliases><alias value="spaced" /></aliases><season number="2"><episode airdate="23 February 2001" arc="none" number="1" title="Back" /><episode airdate="2 March 2001" arc="none" number="2" title="Change" /><episode airdate="9 March 2001" arc="none" number="3" title="Mettle" /><episode airdate="23 March 2001" arc="none" number="4" title="Help" /><episode airdate="None" arc="none" number="5" title="Gone" /><episode airdate="6 April 2001" arc="none" number="6" title="Dissolution" /><episode airdate="13 April 2001" arc="none" number="7" title="Testkonflikt" /></season></tvshow>',
             'spaced.show'),
            ('<tvshow><showproperties backend="imdbtvbackend" duration="30" name="Black Books" url="tt0262150" /><aliases><alias value="blackbooks" /><alias value="black books" /><alias value="black.books" /><alias value="bb" /></aliases><season number="1"><episode airdate="29 September 2000" arc="none" number="1" title="Cooking the Books" /><episode airdate="6 October 2000" arc="none" number="2" title="Manny&apos;s First Day" /><episode airdate="13 October 2000" arc="none" number="3" title="The Grapes of Wrath" /><episode airdate="20 October 2000" arc="none" number="4" title="The Blackout" /><episode airdate="27 October 2000" arc="none" number="5" title="The Big Lock-Out" /><episode airdate="3 November 2000" arc="none" number="6" title="He&apos;s Leaving Home" /></season><season number="2"><episode airdate="1 March 2002" arc="none" number="1" title="The Entertainer" /><episode airdate="8 March 2002" arc="none" number="2" title="Fever" /><episode airdate="15 March 2002" arc="none" number="3" title="The Fixer" /><episode airdate="22 March 2002" arc="none" number="4" title="Blood" /><episode airdate="29 March 2002" arc="none" number="5" title="Hello Sun" /><episode airdate="5 April 2002" arc="none" number="6" title="A Nice Change" /></season><season number="3"><episode airdate="11 March 2004" arc="none" number="1" title="Manny Come Home" /><episode airdate="18 March 2004" arc="none" number="2" title="Elephants and Hens" /><episode airdate="25 March 2004" arc="none" number="3" title="Moo-Ma and Moo-Pa" /><episode airdate="1 April 2004" arc="none" number="4" title="A Little Flutter" /><episode airdate="8 April 2004" arc="none" number="5" title="The Travel Writer" /><episode airdate="15 April 2004" arc="none" number="6" title="Party" /></season></tvshow>',
             'blackbooks.show')
        ]

        self.BaIf1.updateDatabase()

        DB3 = []
        for filename in self.Tools.databaseFiles.values():
            testfile = open(os.path.join(self.Tools.databaseDir, filename),
                            "r")
            content = testfile.read()
            testfile.close()
            DB3.append((content, filename))

        assert DB3 == [
            ('<tvshow><showproperties backend="imdbtvbackend" duration="60" name="Spaced" url="tt0187664" /><aliases /><season number="1"><episode airdate="Sep. 24, 1999" arc="none" number="1" title="Beginnings" /><episode airdate="Oct. 1, 1999" arc="none" number="2" title="Gatherings" /><episode airdate="Oct. 8, 1999" arc="none" number="3" title="Art" /><episode airdate="Oct. 15, 1999" arc="none" number="4" title="Battles" /><episode airdate="Oct. 22, 1999" arc="none" number="5" title="Chaos" /><episode airdate="Oct. 29, 1999" arc="none" number="6" title="Epiphanies" /><episode airdate="Nov. 5, 1999" arc="none" number="7" title="Ends" /></season><season number="2"><episode airdate="23 February 2001" arc="none" number="1" title="Back" /><episode airdate="2 March 2001" arc="none" number="2" title="Change" /><episode airdate="9 March 2001" arc="none" number="3" title="Mettle" /><episode airdate="23 March 2001" arc="none" number="4" title="Help" /><episode airdate="None" arc="none" number="5" title="Gone" /><episode airdate="6 April 2001" arc="none" number="6" title="Dissolution" /><episode airdate="13 April 2001" arc="none" number="7" title="Testkonflikt" /></season></tvshow>',
             'spaced.show'),
            ('<tvshow><showproperties backend="imdbtvbackend" duration="30" name="Black Books" url="tt0262150" /><aliases /><season number="1"><episode airdate="29 September 2000" arc="none" number="1" title="Cooking the Books" /><episode airdate="6 October 2000" arc="none" number="2" title="Manny&apos;s First Day" /><episode airdate="13 October 2000" arc="none" number="3" title="The Grapes of Wrath" /><episode airdate="20 October 2000" arc="none" number="4" title="The Blackout" /><episode airdate="27 October 2000" arc="none" number="5" title="The Big Lock-Out" /><episode airdate="3 November 2000" arc="none" number="6" title="He&apos;s Leaving Home" /></season><season number="2"><episode airdate="1 March 2002" arc="none" number="1" title="The Entertainer" /><episode airdate="8 March 2002" arc="none" number="2" title="Fever" /><episode airdate="15 March 2002" arc="none" number="3" title="The Fixer" /><episode airdate="22 March 2002" arc="none" number="4" title="Blood" /><episode airdate="29 March 2002" arc="none" number="5" title="Hello Sun" /><episode airdate="5 April 2002" arc="none" number="6" title="A Nice Change" /></season><season number="3"><episode airdate="11 March 2004" arc="none" number="1" title="Manny Come Home" /><episode airdate="18 March 2004" arc="none" number="2" title="Elephants and Hens" /><episode airdate="25 March 2004" arc="none" number="3" title="Moo-Ma and Moo-Pa" /><episode airdate="1 April 2004" arc="none" number="4" title="A Little Flutter" /><episode airdate="8 April 2004" arc="none" number="5" title="The Travel Writer" /><episode airdate="15 April 2004" arc="none" number="6" title="Party" /></season></tvshow>',
             'blackbooks.show')
        ]
Exemple #7
0
    def testCompareSeasons(self):

        Episode1 = Episode("2", "What A Title", "6 November, 2008")
        Episode2 = Episode("333", "For A TV Show", "18 November, 2008")
        Episode3 = Episode("4", "What A Title", "6 November, 2008")
        Episode4 = Episode("2", "What A Title", "6 November, 2008")
        Episode5 = Episode("333", "For A TV Show", "18 November, 2008")
        Episode6 = Episode("4", "What A Title", "6 November, 2008")

        Season1 = Season('1')
        Season2 = Season('2')

        Season1.addEpisode(Episode1)
        Season1.addEpisode(Episode2)
        Season1.addEpisode(Episode3)
        Season2.addEpisode(Episode4)
        Season2.addEpisode(Episode5)
        Season2.addEpisode(Episode6)

        assert self.BaIf1.compareSeasons(Season1, Season2).name == "1"
        assert self.BaIf1.compareSeasons(Season1, Season2).name == "1"
Exemple #8
0
    def testCompareDetails(self):

        Episode1 = Episode("2", "What A Title", "6 November, 2008")
        Episode2 = Episode("333", "For A TV Show", "18 November, 2008")
        Episode3 = Episode("4", "What A Title", "6 November, 2008")
        Episode4 = Episode("2", "What A Title", "6 November, 2008")
        Episode5 = Episode("333", "For A TV Show", "18 November, 2008")
        Episode6 = Episode("4", "What A Title", "6 November, 2008")

        Season1 = Season('1')
        Season2 = Season('2')

        Season1.addEpisode(Episode1)
        Season1.addEpisode(Episode2)
        Season1.addEpisode(Episode3)
        Season2.addEpisode(Episode4)
        Season2.addEpisode(Episode5)
        Season2.addEpisode(Episode6)

        Season3 = Season1
        Season4 = Season2

        Show1 = Show("Test Show One", "60", "dummybackend", "dummyurlone")
        Show2 = Show("Test Show Two", "60", "dummybackend", "dummyurltwo")

        Show3 = Show1

        Show1.addSeason(Season1)
        Show1.addSeason(Season2)
        Show2.addSeason(Season3)
        Show2.addSeason(Season4)

        s = self.BaIf1.compareDetails(Show1, Show2)
        assert (s.name, s.duration, s.backend,
                s.url) == ("Test Show One", "60", "dummybackend",
                           "dummyurlone")
        s = self.BaIf1.compareDetails(Show1, Show2)
        assert (s.name, s.duration, s.backend,
                s.url) == ("Test Show One", "60", "dummybackend",
                           "dummyurlone")
Exemple #9
0
    def testFillUpdateDB(self):

        assert os.path.exists(self.Tools.databaseDir) == True

        assert [(show.name, season.name, episode.name, episode.title)
                for show in self.BaIf1.currentDB.database
                for season in show.seasons for episode in season.episodes
                ] == [('C.S.I', '1', '1', 'Pilot'),
                      ('C.S.I', '1', '2', 'Cool Change'),
                      ('C.S.I', '1', '3', "Crate 'n' Burial"),
                      ('C.S.I', '1', '4', 'Pledging Mr. Johnson'),
                      ('C.S.I', '1', '5', 'Friends & Lovers'),
                      ('C.S.I', '1', '6', 'Who Are You?'),
                      ('C.S.I', '1', '7', 'Blood Drops'),
                      ('C.S.I', '1', '8', 'Anonymous'),
                      ('C.S.I', '1', '9', 'Unfriendly Skies'),
                      ('C.S.I', '1', '10', 'Sex, Lies and Larvae'),
                      ('C.S.I', '1', '11', 'I-15 Murders'),
                      ('C.S.I', '1', '12', 'Fahrenheit 932'),
                      ('C.S.I', '1', '13', 'Boom'),
                      ('C.S.I', '1', '14', 'To Halve and to Hold'),
                      ('C.S.I', '1', '15', 'Table Stakes'),
                      ('C.S.I', '1', '16', 'Too Tough to Die'),
                      ('C.S.I', '1', '17', 'Face Lift'),
                      ('C.S.I', '1', '18', '$35K O.B.O.'),
                      ('C.S.I', '1', '19', 'Gentle, Gentle'),
                      ('C.S.I', '1', '20', 'Sounds of Silence'),
                      ('C.S.I', '1', '21', 'Justice Is Served'),
                      ('C.S.I', '1', '22', 'Evaluation Day'),
                      ('C.S.I', '1', '23', 'The Strip Strangler'),
                      ('C.S.I', '2', '1', 'Burked'),
                      ('C.S.I', '2', '2', 'Chaos Theory'),
                      ('C.S.I', '2', '3', 'Overload'),
                      ('C.S.I', '2', '4', 'Bully for You'),
                      ('C.S.I', '2', '5', 'Scuba Doobie-Doo'),
                      ('C.S.I', '2', '6', 'Alter Boys'),
                      ('C.S.I', '2', '7', 'Caged'),
                      ('C.S.I', '2', '8', 'Slaves of Las Vegas'),
                      ('C.S.I', '2', '9', 'And Then There Were None'),
                      ('C.S.I', '2', '10', 'Ellie'),
                      ('C.S.I', '2', '11', 'Organ Grinder'),
                      ('C.S.I', '2', '12', "You've Got Male"),
                      ('C.S.I', '2', '13', 'Identity Crisis'),
                      ('C.S.I', '2', '14', 'The Finger'),
                      ('C.S.I', '2', '15', 'Burden of Proof'),
                      ('C.S.I', '2', '16', 'Primum Non Nocere'),
                      ('C.S.I', '2', '17', 'Felonious Monk'),
                      ('C.S.I', '2', '18', 'Chasing the Bus'),
                      ('C.S.I', '2', '19', 'Stalker'),
                      ('C.S.I', '2', '20', 'Cats in the Cradle...'),
                      ('C.S.I', '2', '21', 'Anatomy of a Lye'),
                      ('C.S.I', '2', '22', 'Cross-Jurisdictions'),
                      ('C.S.I', '2', '23', 'The Hunger Artist'),
                      ('Spaced', '1', '1', 'Beginnings'),
                      ('Spaced', '1', '2', 'Gatherings'),
                      ('Spaced', '1', '3', 'Art'),
                      ('Spaced', '1', '4', 'Battles'),
                      ('Spaced', '1', '5', 'Chaos'),
                      ('Spaced', '1', '6', 'Epiphanies'),
                      ('Spaced', '1', '7', 'Ends'),
                      ('Spaced', '2', '1', 'Back'),
                      ('Spaced', '2', '2', 'Change'),
                      ('Spaced', '2', '3', 'Mettle'),
                      ('Spaced', '2', '4', 'Help'),
                      ('Spaced', '2', '5', 'Gone'),
                      ('Spaced', '2', '6', 'Dissolution'),
                      ('Spaced', '2', '7', 'Testkonflikt'),
                      ('Black Books', '1', '1', 'Cooking the Books'),
                      ('Black Books', '1', '2', "Manny's First Day"),
                      ('Black Books', '1', '3', 'The Grapes of Wrath'),
                      ('Black Books', '1', '4', 'The Blackout'),
                      ('Black Books', '1', '5', 'The Big Lock-Out'),
                      ('Black Books', '1', '6', "He's Leaving Home"),
                      ('Black Books', '2', '1', 'The Entertainer'),
                      ('Black Books', '2', '2', 'Fever'),
                      ('Black Books', '2', '3', 'The Fixer'),
                      ('Black Books', '2', '4', 'Blood'),
                      ('Black Books', '2', '5', 'Hello Sun'),
                      ('Black Books', '2', '6', 'A Nice Change'),
                      ('Black Books', '3', '1', 'Manny Come Home'),
                      ('Black Books', '3', '2', 'Elephants and Hens'),
                      ('Black Books', '3', '3', 'Moo-Ma and Moo-Pa'),
                      ('Black Books', '3', '4', 'A Little Flutter'),
                      ('Black Books', '3', '5', 'The Travel Writer'),
                      ('Black Books', '3', '6', 'Party')]

        show1 = self.BaIf1.currentDB.getShow(
            Show('Spaced', '30', 'imdbtvbackend', 'tt000000'))
        show1.removeSeason(Season('1'))

        assert [(show.name, season.name, episode.name, episode.title)
                for show in self.BaIf1.currentDB.database
                for season in show.seasons for episode in season.episodes
                ] == [('C.S.I', '1', '1', 'Pilot'),
                      ('C.S.I', '1', '2', 'Cool Change'),
                      ('C.S.I', '1', '3', "Crate 'n' Burial"),
                      ('C.S.I', '1', '4', 'Pledging Mr. Johnson'),
                      ('C.S.I', '1', '5', 'Friends & Lovers'),
                      ('C.S.I', '1', '6', 'Who Are You?'),
                      ('C.S.I', '1', '7', 'Blood Drops'),
                      ('C.S.I', '1', '8', 'Anonymous'),
                      ('C.S.I', '1', '9', 'Unfriendly Skies'),
                      ('C.S.I', '1', '10', 'Sex, Lies and Larvae'),
                      ('C.S.I', '1', '11', 'I-15 Murders'),
                      ('C.S.I', '1', '12', 'Fahrenheit 932'),
                      ('C.S.I', '1', '13', 'Boom'),
                      ('C.S.I', '1', '14', 'To Halve and to Hold'),
                      ('C.S.I', '1', '15', 'Table Stakes'),
                      ('C.S.I', '1', '16', 'Too Tough to Die'),
                      ('C.S.I', '1', '17', 'Face Lift'),
                      ('C.S.I', '1', '18', '$35K O.B.O.'),
                      ('C.S.I', '1', '19', 'Gentle, Gentle'),
                      ('C.S.I', '1', '20', 'Sounds of Silence'),
                      ('C.S.I', '1', '21', 'Justice Is Served'),
                      ('C.S.I', '1', '22', 'Evaluation Day'),
                      ('C.S.I', '1', '23', 'The Strip Strangler'),
                      ('C.S.I', '2', '1', 'Burked'),
                      ('C.S.I', '2', '2', 'Chaos Theory'),
                      ('C.S.I', '2', '3', 'Overload'),
                      ('C.S.I', '2', '4', 'Bully for You'),
                      ('C.S.I', '2', '5', 'Scuba Doobie-Doo'),
                      ('C.S.I', '2', '6', 'Alter Boys'),
                      ('C.S.I', '2', '7', 'Caged'),
                      ('C.S.I', '2', '8', 'Slaves of Las Vegas'),
                      ('C.S.I', '2', '9', 'And Then There Were None'),
                      ('C.S.I', '2', '10', 'Ellie'),
                      ('C.S.I', '2', '11', 'Organ Grinder'),
                      ('C.S.I', '2', '12', "You've Got Male"),
                      ('C.S.I', '2', '13', 'Identity Crisis'),
                      ('C.S.I', '2', '14', 'The Finger'),
                      ('C.S.I', '2', '15', 'Burden of Proof'),
                      ('C.S.I', '2', '16', 'Primum Non Nocere'),
                      ('C.S.I', '2', '17', 'Felonious Monk'),
                      ('C.S.I', '2', '18', 'Chasing the Bus'),
                      ('C.S.I', '2', '19', 'Stalker'),
                      ('C.S.I', '2', '20', 'Cats in the Cradle...'),
                      ('C.S.I', '2', '21', 'Anatomy of a Lye'),
                      ('C.S.I', '2', '22', 'Cross-Jurisdictions'),
                      ('C.S.I', '2', '23', 'The Hunger Artist'),
                      ('Spaced', '2', '1', 'Back'),
                      ('Spaced', '2', '2', 'Change'),
                      ('Spaced', '2', '3', 'Mettle'),
                      ('Spaced', '2', '4', 'Help'),
                      ('Spaced', '2', '5', 'Gone'),
                      ('Spaced', '2', '6', 'Dissolution'),
                      ('Spaced', '2', '7', 'Testkonflikt'),
                      ('Black Books', '1', '1', 'Cooking the Books'),
                      ('Black Books', '1', '2', "Manny's First Day"),
                      ('Black Books', '1', '3', 'The Grapes of Wrath'),
                      ('Black Books', '1', '4', 'The Blackout'),
                      ('Black Books', '1', '5', 'The Big Lock-Out'),
                      ('Black Books', '1', '6', "He's Leaving Home"),
                      ('Black Books', '2', '1', 'The Entertainer'),
                      ('Black Books', '2', '2', 'Fever'),
                      ('Black Books', '2', '3', 'The Fixer'),
                      ('Black Books', '2', '4', 'Blood'),
                      ('Black Books', '2', '5', 'Hello Sun'),
                      ('Black Books', '2', '6', 'A Nice Change'),
                      ('Black Books', '3', '1', 'Manny Come Home'),
                      ('Black Books', '3', '2', 'Elephants and Hens'),
                      ('Black Books', '3', '3', 'Moo-Ma and Moo-Pa'),
                      ('Black Books', '3', '4', 'A Little Flutter'),
                      ('Black Books', '3', '5', 'The Travel Writer'),
                      ('Black Books', '3', '6', 'Party')]

        self.BaIf1.currentDB.removeShow(
            Show('C.S.I', '60', 'imdbtvbackend', 'tt000000'))

        assert [(show.name, season.name, episode.name, episode.title)
                for show in self.BaIf1.currentDB.database
                for season in show.seasons for episode in season.episodes
                ] == [('Spaced', '2', '1', 'Back'),
                      ('Spaced', '2', '2', 'Change'),
                      ('Spaced', '2', '3', 'Mettle'),
                      ('Spaced', '2', '4', 'Help'),
                      ('Spaced', '2', '5', 'Gone'),
                      ('Spaced', '2', '6', 'Dissolution'),
                      ('Spaced', '2', '7', 'Testkonflikt'),
                      ('Black Books', '1', '1', 'Cooking the Books'),
                      ('Black Books', '1', '2', "Manny's First Day"),
                      ('Black Books', '1', '3', 'The Grapes of Wrath'),
                      ('Black Books', '1', '4', 'The Blackout'),
                      ('Black Books', '1', '5', 'The Big Lock-Out'),
                      ('Black Books', '1', '6', "He's Leaving Home"),
                      ('Black Books', '2', '1', 'The Entertainer'),
                      ('Black Books', '2', '2', 'Fever'),
                      ('Black Books', '2', '3', 'The Fixer'),
                      ('Black Books', '2', '4', 'Blood'),
                      ('Black Books', '2', '5', 'Hello Sun'),
                      ('Black Books', '2', '6', 'A Nice Change'),
                      ('Black Books', '3', '1', 'Manny Come Home'),
                      ('Black Books', '3', '2', 'Elephants and Hens'),
                      ('Black Books', '3', '3', 'Moo-Ma and Moo-Pa'),
                      ('Black Books', '3', '4', 'A Little Flutter'),
                      ('Black Books', '3', '5', 'The Travel Writer'),
                      ('Black Books', '3', '6', 'Party')]

        print self.BaIf1.dbDir

        self.BaIf1.updateDB.printDb()

        self.BaIf1.fillUpdateDB()

        self.BaIf1.updateDB.printDb()

        self.BaIf1.currentDB.printDb()

        self.BaIf1.mergeDB.printDb()

        assert [
            (show.name, season.name, episode.name, episode.title)
            for show in self.BaIf1.mergeDB.database for season in show.seasons
            for episode in season.episodes
        ] == [('Spaced', '1', '1', 'Beginnings'),
              ('Spaced', '1', '2', 'Gatherings'), ('Spaced', '1', '3', 'Art'),
              ('Spaced', '1', '4', 'Battles'), ('Spaced', '1', '5', 'Chaos'),
              ('Spaced', '1', '6', 'Epiphanies'), ('Spaced', '1', '7', 'Ends'),
              ('Spaced', '2', '1', 'Back'), ('Spaced', '2', '2', 'Change'),
              ('Spaced', '2', '3', 'Mettle'), ('Spaced', '2', '4', 'Help'),
              ('Spaced', '2', '5', 'Gone'),
              ('Spaced', '2', '6', 'Dissolution'),
              ('Spaced', '2', '7', 'Testkonflikt'),
              ('Black Books', '1', '1', 'Cooking the Books'),
              ('Black Books', '1', '2', "Manny's First Day"),
              ('Black Books', '1', '3', 'The Grapes of Wrath'),
              ('Black Books', '1', '4', 'The Blackout'),
              ('Black Books', '1', '5', 'The Big Lock-Out'),
              ('Black Books', '1', '6', "He's Leaving Home"),
              ('Black Books', '2', '1', 'The Entertainer'),
              ('Black Books', '2', '2', 'Fever'),
              ('Black Books', '2', '3', 'The Fixer'),
              ('Black Books', '2', '4', 'Blood'),
              ('Black Books', '2', '5', 'Hello Sun'),
              ('Black Books', '2', '6', 'A Nice Change'),
              ('Black Books', '3', '1', 'Manny Come Home'),
              ('Black Books', '3', '2', 'Elephants and Hens'),
              ('Black Books', '3', '3', 'Moo-Ma and Moo-Pa'),
              ('Black Books', '3', '4', 'A Little Flutter'),
              ('Black Books', '3', '5', 'The Travel Writer'),
              ('Black Books', '3', '6', 'Party')]
Exemple #10
0
 def setUp(self) :
     self.season = Season("100")
Exemple #11
0
class testSeason :
    """
    Test Season Class
    """
    def setUp(self) :
        self.season = Season("100")
        
    def testAddEpisode(self) :
        Episode1 = Episode( "2", "What A Title", "6 November, 2008" )
        Episode2 = Episode( "333", "For A TV Show", "18 November, 2008" )
        Episode3 = Episode( "4", "What A Title", "6 November, 2008")
        assert self.season.addEpisode( Episode1 ) == Episode1
        assert self.season.addEpisode( Episode1 ) == None
        assert self.season.addEpisode( Episode2 ) == Episode2
        assert self.season.addEpisode( Episode( "333", "For A TV Show", "18 November, 2008" ) ) == None
        assert self.season.addEpisode( Episode3 ) == Episode3
        
    def testGetEpisode(self) :
        Episode1 = Episode( "2", "What A Title", "6 November, 2008" )
        Episode2 = Episode( "333", "For A TV Show", "18 November, 2008" )
        Episode3 = Episode( "4", "What A Title", "6 November, 2008")
        self.season.addEpisode( Episode1 )
        self.season.addEpisode( Episode2 )
        assert self.season.getEpisode( Episode1 ) == Episode1
        assert self.season.getEpisode( Episode3 ) == None
        assert self.season.getEpisode( Episode( "333", "For A TV Show", "18 November, 2008" ) ) == Episode2
        assert self.season.getEpisode( Episode( "4", "What A Title", "6 November, 2008") ) == None
        
    def testRemoveEpisode(self) :
        Episode1 = Episode( "2", "What A Title", "6 November, 2008" )
        Episode2 = Episode( "333", "For A TV Show", "18 November, 2008" )
        Episode3 = Episode( "4", "What A Title", "6 November, 2008")
        self.season.addEpisode( Episode1 )
        self.season.addEpisode( Episode2 )
        assert self.season.removeEpisode( Episode1 ) == Episode1
        assert self.season.removeEpisode( Episode1 ) == None
        assert self.season.removeEpisode( Episode( "4", "What A Title", "6 November, 2008" ) ) == None
        assert self.season.removeEpisode( Episode( "333", "For A TV Show", "18 November, 2008" ) ) == Episode2
Exemple #12
0
    def getShowDetails ( self, showandseasonsdict ) :
        '''
        Download a list of Show object's episodes.
        
        :param showandcontentlist: dictionary { Show : content( raw html from web page ) }
        :type showandcontentlist: :mod:`dict`
        :returns: Database with api.dbapi.Show objects
        :rtype: :class:`api.dbapi.Database`
        '''
        updateDB = Database()
        #TODO: Test for changes in code.
        for Show, seasons in showandseasonsdict.items() :
            
            for season, episodes in seasons.items() :
                
                for episode in episodes :
                    
                    assert season == episode["season"]
                    
                    #print episode["episode"]
                    
                    episodenr = episode["episode"].findAll('meta', { "itemprop" : "episodeNumber" })[0]["content"]
                    #print episodenr
                    
                    episodename = episode["episode"].findAll('a', { "itemprop" : "name" })[0]["title"]
                    #print episodename
                    
                    episodeairdate = episode["episode"].findAll('div', { "class" : "airdate" })[0].string.strip()
                    #print episodeairdate
                    
                    Show.addEpisode( Episode( episodenr, episodename, episodeairdate ), Season( season ) )
            
            updateDB.addShow( Show )
                
#            seasons = BeautifulSoup.SoupStrainer('div', { "class" : re.compile("season-filter-all filter-season-[0-9]+") })
#            
#            all = [ tag for tag in BeautifulSoup.BeautifulSoup( content, parseOnlyThese=seasons)]
#            
#            for i in xrange( 0, len(all)) :
#                ## Remove rubbish from the content.
#                [ tag.extract() for tag in all[i].findAll('hr') ]
#                [ tag.parent.extract() for tag in all[i].findAll('a', { "name" : re.compile("season-[0-9]+")} )]
#            
#            regexp = Regexes()
#            
#            for x in all :
#                for item in x.findAll('div', { "class" : re.compile("filter-all filter-year-[0-9]+")} ) :
#                    ## Extract info in every episode/item, and add to one tuple
#                    merge = regexp.extractEpSeTitle( str(item.find('h3')) ) + regexp.extractAirDate( str( item.find('strong') ) )
#                    if ( len(merge) == 4 ) : ## If merge is proper
#                        Show.addEpisode( Episode( merge[1], regexp.removeEntities(merge[2]), merge[3] ), Season( merge[0] ) )
#            updateDB.addShow( Show )
        
        return updateDB