def testGetAllLocal(self): ps = packages.get_all_local() for p in ps: self.assertIsInstance(p, packages.Package) self.assertTrue(p.local.exists, msg="%s doesn't exist"%p.id) # TODO: Some better tests for this function. self.assertEqual(len(ps), 11)
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()