Пример #1
0
 def setUp(self):
     options.working_dir = 'temp'
     reload(database_update)
     with open(options.get_cfg(),'w') as cfg:
         cfg.write(self.cfg_text)
     database_update.update_remote()
     database_update.update_local()
Пример #2
0
            def run(thread):

                with warnings.catch_warnings(record=True) as w:
                    warnings.filterwarnings('always')

                    self.statusbar.push(self.cid,
                        'Updating remote package list...')
                    database_update.update_remote()
                    self.statusbar.pop(self.cid)

                    self.statusbar.push(self.cid,
                        'Updating local package list...')
                    database_update.update_local()
                    self.statusbar.pop(self.cid)

                self.update_treeview()

                for msg in w:
                    self.show_error(str(msg.message))
Пример #3
0
    def testMissingTables(self):
        os.remove(options.get_database())
        reload(database_update) # To trigger base table creation.
        database_update.update_local()

        # Empty index table.
        p = packages.Package('not-even-real')
        self.assertFalse(p.local.exists)
        self.assertItemsEqual(p.remote, [])
        self.assertEqual(len(packages.get_all_local()), len(packages.get_all()))

        # Table in index, but doesn't successfully reach it.
        with open(options.get_cfg()) as f:
            txt = f.read()
        new = txt.split('\n')
        new.insert(2, '"http://notreal.ihope",')
        with open(options.get_cfg(), 'w') as f:
            f.write('\n'.join(new))
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            database_update.update_remote()
        packages.get_all()
Пример #4
0
 def testRemove(self):
     # Create a slightly-modified sacrificial file.
     src = open(os.path.join(testfiles, 'fulltest.pnd')).read()
     dstpath = os.path.join(testfiles, 'fulltest2.pnd')
     with open(dstpath,'w') as dst:
         dst.write(src.replace('sample-package', 'sample2', 1))
     # Make sure it gets in the database.
     database_update.update_local()
     with sqlite3.connect(options.get_database()) as db:
         self.assertIsNotNone( db.execute(
             'Select * From "%s" Where id="sample2"'
             % database_update.LOCAL_TABLE).fetchone() )
     # Now remove it!
     p = packages.Package('sample2')
     p.remove()
     # And make sure it's gone.
     self.assertFalse(os.path.exists(dstpath))
     with sqlite3.connect(options.get_database()) as db:
         self.assertIsNone( db.execute(
             'Select * From "%s" Where id="sample2"'
             % database_update.LOCAL_TABLE).fetchone() )
     self.assertFalse(p.local.exists)
Пример #5
0
 def testUpdateLocal(self):
     database_update.update_local()
     db = sqlite3.connect(options.get_database())
     db.row_factory = sqlite3.Row
     #Check that database has correct entries.
     c = db.execute('Select * From "%s" Where id="bubbman2"'
         %database_update.LOCAL_TABLE)
     i = c.fetchone()
     self.assertEqual(i['id'], 'bubbman2')
     self.assertEqual(i['version'], '1.0.3.1')
     self.assertEqual(i['author_name'], "pymike")
     self.assertEqual(i['author_website'],
         "http://www.pygame.org/project-BubbMan+2-1114-.html")
     self.assertEqual(i['author_email'], None)
     self.assertEqual(i['title'], "BubbMan2")
     self.assertEqual(i['description'], "A solo entry by pymike for PyWeek #8")
     self.assertEqual(i['icon'], 'data/logo.png')
     self.assertEqual(i['uri'], os.path.join(testfiles, 'BubbMan2.pnd'))
     #self.assertEqual(i['md5'], '84c81afa183561f0bb7b2db692646833')
     self.assertEqual(i['vendor'], None)
     self.assertEqual(i['rating'], None)
     self.assertEqual(i['applications'], 'bubbman2')
     self.assertEqual(i['previewpics'], None)
     self.assertEqual(i['licenses'], None)
     self.assertEqual(i['source'], None)
     self.assertEqual(i['categories'], "Game;ActionGame")
     c = db.execute('Select * From "%s" Where id="sparks"'
         %database_update.LOCAL_TABLE)
     i = c.fetchone()
     self.assertEqual(i['id'], 'sparks')
     self.assertEqual(i['version'], '0.4.2.0')
     self.assertEqual(i['author_name'], "Haltux")
     self.assertEqual(i['author_website'], "https://github.com/haltux")
     self.assertEqual(i['author_email'], None)
     self.assertEqual(i['title'], "Sparks")
     self.assertEqual(i['description'], "A vectorial shooter")
     self.assertEqual(i['icon'], 'icon.png')
     self.assertEqual(i['uri'], os.path.join(testfiles, 'Sparks-0.4.2.pnd'))
     #self.assertEqual(i['md5'], 'fb10014578bb3f0c0ae8e88a0fd81121')
     self.assertEqual(i['vendor'], None)
     self.assertEqual(i['rating'], None)
     self.assertEqual(i['applications'], 'sparks')
     self.assertEqual(i['previewpics'], None)
     self.assertEqual(i['licenses'], None)
     self.assertEqual(i['source'], None)
     self.assertEqual(i['categories'], "Game;ArcadeGame")
     c = db.execute('Select * From "%s" Where id="the-lonely-tower"'
         %database_update.LOCAL_TABLE)
     i = c.fetchone()
     self.assertEqual(i['id'], 'the-lonely-tower')
     self.assertEqual(i['version'], '2.2.0.0')
     self.assertEqual(i['author_name'], "Randy Heydon")
     self.assertEqual(i['author_website'],
         "http://randy.heydon.selfip.net/Programs/The Lonely Tower/")
     self.assertEqual(i['author_email'], None)
     self.assertEqual(i['title'], "The Lonely Tower")
     self.assertEqual(i['description'], "A dumb arty game made for a competition.")
     self.assertEqual(i['icon'],
         'lonelytower/assets/male-brunette-angry-listening-notrans.png')
     self.assertEqual(i['uri'], os.path.join(testfiles, 'The Lonely Tower-2.2.pnd'))
     #self.assertEqual(i['md5'], '0314d0f7055052cd91ec608d63acad2a')
     self.assertEqual(i['vendor'], None)
     self.assertEqual(i['rating'], None)
     self.assertEqual(i['applications'], 'the-lonely-tower')
     self.assertEqual(i['previewpics'], None)
     self.assertEqual(i['licenses'], None)
     self.assertEqual(i['source'], None)
     self.assertEqual(i['categories'], "Game;RolePlaying")
     c = db.execute('Select * From "%s" Where id="sample-package"'
         %database_update.LOCAL_TABLE)
     i = c.fetchone()
     self.assertEqual(i['id'], 'sample-package')
     self.assertEqual(i['version'], '1.0.0.0')
     self.assertEqual(i['author_name'], "packagers name")
     self.assertEqual(i['author_website'], "http://www.website.foo")
     self.assertEqual(i['author_email'], "*****@*****.**")
     self.assertEqual(i['title'], "Sample Collection")
     self.assertEqual(i['description'],
         "This is a really verbose package with a whole lot of stuff from 2 different sources, mixing different things, having stuff in ways sometimes making use of stuff, often not.")
     self.assertEqual(i['icon'], "my-icon.png")
     self.assertEqual(i['uri'], os.path.join(testfiles, 'fulltest.pnd'))
     #self.assertEqual(i['md5'], '201f7b98cc4933cd728087b548035b71')
     self.assertEqual(i['vendor'], None)
     self.assertEqual(i['rating'], None)
     self.assertEqual(i['applications'],
         'sample-app1;sample-app2;sample-app3')
     self.assertEqual(i['previewpics'],
         'preview-image.png;application_1.png;different-preview-image.png')
     # TODO: Add support for license reading, then enable these tests.
     #self.assertEqual(i['licenses'],
     #    'I do as I please;other;Qt-commercial;public domain;GPLv2+;GPLv2+')
     #self.assertEqual(i['source'],
     #    'git://git.openpandora.org;http://pandora.org/sources/package.tar.bz2')
     self.assertEqual(i['categories'],
         "Game;Emulator;System;Emulator;Game;StrategyGame;System")
     c = db.execute('Select * From "%s" Where id="chromium-dev"'
         %database_update.LOCAL_TABLE)
     i = c.fetchone()
     self.assertEqual(i['id'], 'chromium-dev')
     self.assertEqual(i['version'], '10.0.642.1')
     self.assertEqual(i['author_name'], "")
     self.assertEqual(i['author_website'], "http://sites.google.com/a/chromium.org/dev/")
     self.assertEqual(i['author_email'], None)
     self.assertEqual(i['title'], "Chromium-Dev")
     self.assertEqual(i['description'],
         u"Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web. This site contains design documents, architecture overviews, testing information, and more to help you learn to build and work with the Chromium source code.\u201d.")
     self.assertEqual(i['icon'], "product_logo_48.png")
     self.assertEqual(i['uri'], os.path.join(testfiles, 'Chromium-dev.pxml.pnd'))
     #self.assertEqual(i['md5'], 'ec93f8e51b50be4ee51d87d342a6028a')
     self.assertEqual(i['vendor'], None)
     self.assertEqual(i['rating'], None)
     self.assertEqual(i['applications'], 'chromium-dev')
     self.assertEqual(i['previewpics'], './preview.jpg')
     self.assertEqual(i['licenses'], None)
     self.assertEqual(i['source'], None)
     self.assertEqual(i['categories'], 'Network;WebBrowser')