def main(): print ("Start of process...") #configuration parameters start = time.time() txt_path = config.conf["txt_path"] save_path = config.conf["save_path"] database_path = config.conf["database_path"] db_type = config.conf["db_type"] #use plaintext abstract factory txt_abs_factory = plaintext_abs_factory.plaintext_factory() txt_factory = txt_abs_factory.get_plaintext(txt_path) txt_prod = txt_factory.get_txt() URLs = txt_prod.get_lines() #use images abstract factory init_pics = Pic_Handler(URLs,save_path) pics_info = init_pics.pic_info() init_pics.pic_save() #use database abstract factory db_abs_factory = database_abs_factory.database_factory() db_factory = db_abs_factory.db_abs_fac(db_type,database_path) db_prod = db_factory.process_sql() db_prod.create_db() db_prod.populate_db(pics_info) print ("End of process" ) end = time.time() print ("Process time: ", str(round(end-start,2)),"sec") raw_input("Press enter to exit.")
class Test_pic_handler(unittest.TestCase): def setUp(self): self.__url = ["http://bilder.bild.de/fotos/lachsack-36229038/Bild/1.bild.jpg"] self.__save_path = "test_files" self.__pic = Pic_Handler(self.__url,self.__save_path) def test_pic_save(self): ''' Method to test if the Save_Pic class returns 1 ''' self.assertEqual( self.__pic.pic_save(), 1) def test_pic_info(self): ''' Method to test if the Save_Pic class returns the right information. ''' pic_info = self.__pic.pic_info() self.assertNotIn("/", pic_info[0][0]) self.assertNotIn(":", pic_info[0][0]) self.assertIn("http://", pic_info[0][1]) self.assertEqual(type (pic_info[0][2]), str)