コード例 #1
0
    def testFileFilter(self):
        
        globalContext = Bootstraper()
        globalContext.boot()
        
        app = globalContext.app

        items = []
        
        positiveItem = self.createPositiveItem()
        negativeItem = self.createNegativeItem()
        
        positiveItemSecondCriteria = copy.copy(positiveItem)
        positiveItemSecondCriteria.title = "MagicString - 123 - face.mcfh"
        
        items.append(positiveItem)
        items.append(positiveItemSecondCriteria)
        items.append(negativeItem)
        
        rawConfiguration = {
                            'file': 'filter.txt',
                            'type': 'regex',
                            'property': 'title'}
                
        testFilter = Filter(rawConfiguration, "Test Filter")
        
        filters = {testFilter}
        
        filteredItems = app.filterItems(items, filters)
        
        self.assertEqual(2, len(filteredItems), "There should be two items left in filtered item list.")
        
        for item in filteredItems:
            
            self.assertTrue("Satisfaction" in item.title or "MagicString" in item.title, "Title should contain one item with 'Satisfaction' in it's title.")
コード例 #2
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)
コード例 #3
0
 def testBootstraper(self):
     
     globalContext = Bootstraper()
     
     globalContext.boot();
     
     self.assertIsNotNone(globalContext.app, "Bootstraper shall construct the app object.")
     self.assertIsNotNone(globalContext.configuration, "Bootstraper shall construct a configuration.")
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
    def testCheckExisting(self):
        
        globalContext = Bootstraper()
        globalContext.boot()
        
        app = globalContext.app

        items = []
        
        item = self.createPositiveItem()
        
        items.append(item)
        
        otherItem = copy.copy(item)
        items.append(item)
        items.append(self.createNegativeItem())
        
        source = next(iter(app.sources.values()))
        destination = next(iter(app.destinations.values()))
        firstFilter = app.filters["nameRegex"]
    
        self.assertEqual("tv", destination.name)
        self.assertEqual(destination.name, source.defaultDestination)
        self.assertEqual(destination.name, firstFilter.destination)
        
        self.assertEqual("start.tv", source.directory)
        self.assertEqual("download.tv", destination.directory)
        
        app.sqlLiteClientFactory = MockSqlLiteClientFactory()
        
        exists = app.checkExists(item)
        
        self.assertFalse(exists, "Item shall not exist before it is marked downloaded.");
        
        app.markDownloaded(item)
        
        exists = app.checkExists(item)
        
        self.assertTrue(exists)
コード例 #7
0
 def testPullParseData(self):
     
     globalContext = Bootstraper()
     globalContext.boot();
     app = globalContext.app
     
     assert isinstance(app, App)
     
     rawFeedBytes =  open('./feed.xml', mode='r', encoding='utf-8').read() #app.pullBytes(app.source)
     
     self.assertIsNotNone(rawFeedBytes)
     self.assertTrue(len(rawFeedBytes) > 0, "The length of the rss feed shall not be 0.")
     
     feedTree = XML(rawFeedBytes)
     
     self.assertIsNotNone(feedTree)
     
     self.assertTrue(feedTree[0].tag == "channel")
     
     itemElements = feedTree[0].findall('item')
     self.assertTrue(0 < len(itemElements))
     
     for itemElement in itemElements:
         
         self.assertIsNotNone(itemElement.find('title'))
         self.assertIsNotNone(itemElement.find('description'))
         self.assertIsNotNone(itemElement.find('link'))
     
     items = app.parseBytes(rawFeedBytes)
     
     for item in items:
         
         self.assertIsNotNone(item)
         self.assertIsNotNone(item.title)
         self.assertIsNotNone(item.description)
         self.assertIsNotNone(item.timestamp)
         self.assertIsInstance(item.timestamp, time.struct_time)
         self.assertIsNotNone(item.rawTimestamp)
         self.assertIsNotNone(item.link)
コード例 #8
0
    def testFilter(self):
        
        
        globalContext = Bootstraper()
        globalContext.boot()
        
        app = globalContext.app
        
        configuration = app.configuration

        items = []
        
        positiveItem = self.createPositiveItem()
        negativeItem = self.createNegativeItem()
        
        items.append(positiveItem)
        items.append(negativeItem)
        
        rawConfiguration = {
                            'file': None,
                            'expression': '.*Satisfaction.*',
                            'type': 'regex',
                            'property': 'title'}
                
        testFilter = Filter(rawConfiguration, "Test Filter")
        
        filters = {testFilter}
        
        filteredItems = app.filterItems(items, filters)
        
        self.assertEqual(1, len(filteredItems), "There should be only one item left in filtered item list.")
        
        for item in filteredItems:
            
            self.assertTrue("Satisfaction" in item.title, "Title should contain one item with 'Satisfaction' in it's title.")
        
        pass
コード例 #9
0
ファイル: mediaSync.py プロジェクト: kmacmcfarlane/MediaSync
'''
Created on Jul 20, 2013

@author: Kyle
'''
from mediaSync.bootstraper import Bootstraper

if __name__ == '__main__':
    
    # Bootstrap application
    bootstrapper = Bootstraper()
    bootstrapper.boot()
    
    # 
    context = bootstrapper.app