예제 #1
0
 def testLoadFilter(self):
     configuration = Configuration("./")
     
     rawConfiguration = configuration.parseFile(configuration.openConfFile("./"))
     
     nameFilter = Filter(rawConfiguration["filters"]["nameRegex"], "nameRegex")
     
     self.assertEqual("filter.txt", nameFilter.file)
     self.assertEqual("regex", nameFilter.type)
     self.assertEqual("title", nameFilter.property)
     
     resolutionFilter = Filter(rawConfiguration["filters"]["resolutionRegex"], "resolutionRegex")
     
     self.assertEqual("\[\ 720p\ \]", resolutionFilter.expression)
     self.assertEqual("regex", resolutionFilter.type)
     self.assertEqual("title", resolutionFilter.property)
     
             
     globalContext = Bootstraper()
     globalContext.boot()
     
     app = globalContext.app
     
     self.assertIsNotNone(app.filters["nameRegex"])
     
     self.assertEqual("filter.txt", app.filters["nameRegex"].file)
     self.assertEqual("regex", app.filters["nameRegex"].type)
     self.assertEqual("title", app.filters["nameRegex"].property)
     
     self.assertIsNotNone(app.filters["resolutionRegex"])
     
     self.assertEqual("\[\ 720p\ \]", app.filters["resolutionRegex"].expression)
     self.assertEqual("regex", app.filters["resolutionRegex"].type)
     self.assertEqual("title", app.filters["resolutionRegex"].property)
예제 #2
0
 def testLoadDestination(self):
     
     configuration = Configuration("./")
     
     rawConfiguration = configuration.parseFile(configuration.openConfFile("./"))
     
     destination = Destination(rawConfiguration["destinations"]["tv"], "tv")
     
     self.assertEqual("tv", destination.name)
     self.assertEqual("download.tv", destination.directory)
     
     
     globalContext = Bootstraper()
     globalContext.boot()
     
     app = globalContext.app
     
     self.assertEqual("tv", destination.name)
     self.assertEqual("download.tv", destination.directory)
예제 #3
0
    def testLoadConfiguration(self):
        
        searchPath = "./" # mediaSync/test
        configuration = Configuration(searchPath)
        
        configurationFile = configuration.openConfFile(searchPath)
        
        self.assertIsNotNone(configurationFile, "Test configuration file shall be present. CWD=" + os.getcwd())
        
        rawConfiguration = configuration.parseFile(configurationFile)
        
        self.assertIsNotNone(rawConfiguration, "The configuration file shall be parsed as JSON.")
        self.assertIsNotNone(rawConfiguration["sources"], "The configuration file shall contain a source." )
        self.assertIsNotNone(rawConfiguration["destinations"], "The configuration file shall contain a destination." )
        self.assertIsNotNone(rawConfiguration["filters"], "The configuration file shall contain filters." )
        
        self.assertIsNotNone(configuration.sources, "The configuration object shall contain a source.")
        self.assertIsNotNone(configuration.destinations, "The configuration object shall contain a destination.")
        self.assertIsNotNone(configuration.filters, "The configuration object shall contain filters.")


        self.assertEqual("btn", configuration.sources["btn"].name, "The source must contain the correct name.")
        self.assertEqual("https://broadcasthe.net/feeds.php?feed=torrents_episode&user=1485399&auth=4944d992c85b5ff93f1bb715ad68c671&passkey=tkfh3yf4o60c8nlyxny0x7lrqpg77k1a&authkey=ff9be6ee72a2a26d365f4454a98db5f6", configuration.sources["btn"].uri, "The source must contain the correct URI.")
        self.assertEqual("start.tv", configuration.sources["btn"].directory, "The source must contain the correct descriptor directory.")
        
        self.assertEqual("tv", configuration.destinations["tv"].name, "The destination must contain the correct name.")
        self.assertEqual("download.tv", configuration.destinations["tv"].directory, "The destination must contain the correct URI.")

        self.assertTrue(len(configuration.filters) > 0)
        
        self.assertEqual("filter.txt", configuration.filters["nameRegex"].file, "The filter must contain the correct file.")
        self.assertEqual("regex", configuration.filters["nameRegex"].type, "The filter must contain the correct type.")
        self.assertEqual("title", configuration.filters["nameRegex"].property, "The filter must contain the correct type.")
        
        self.assertEqual("\[\ 720p\ \]", configuration.filters["resolutionRegex"].expression, "The filter must contain the correct file.")
        self.assertEqual("regex", configuration.filters["resolutionRegex"].type, "The filter must contain the correct type.")
        self.assertEqual("title", configuration.filters["resolutionRegex"].property, "The filter must contain the correct type.")
                
        # Bad File
        badFile = configuration.openConfFile("./badConfiguration")
        
        self.assertRaises(ValueError, configuration.parseFile, badFile)
예제 #4
0
 def testLoadSource(self):
     configuration = Configuration("./")
     rawConfiguration = configuration.parseFile(configuration.openConfFile("./"))
     
     source = Source(rawConfiguration["sources"]["btn"], "btn")
     
     self.assertEqual("btn", source.name)
     self.assertEqual("https://broadcasthe.net/feeds.php?feed=torrents_episode&user=1485399&auth=4944d992c85b5ff93f1bb715ad68c671&passkey=tkfh3yf4o60c8nlyxny0x7lrqpg77k1a&authkey=ff9be6ee72a2a26d365f4454a98db5f6", source.uri)
     self.assertEqual("start.tv", source.directory)
     self.assertEqual("nameRegex,resolutionRegex", source.filters)
     
     
     globalContext = Bootstraper()
     globalContext.boot()
     
     app = globalContext.app
     
     self.assertEqual("btn", app.sources["btn"].name)
     self.assertEqual("https://broadcasthe.net/feeds.php?feed=torrents_episode&user=1485399&auth=4944d992c85b5ff93f1bb715ad68c671&passkey=tkfh3yf4o60c8nlyxny0x7lrqpg77k1a&authkey=ff9be6ee72a2a26d365f4454a98db5f6", app.sources["btn"].uri)
     self.assertEqual("start.tv", app.sources["btn"].directory)
     self.assertEqual("nameRegex,resolutionRegex", app.sources["btn"].filters)