def test_add_next_task_02(self): """ Invalid book """ try: book_title = "BLBLB_title" app = Apptt_meta(short_name="BLBLB_tt2", title=book_title) app.add_task(task_info=dict(link="http://archive.org/download/livro1/n1", page=1)) app.add_task(task_info=dict(link="http://archive.org/download/livro1/n2", page=2)) tasks = pbclient.get_tasks(app_id=app.app_id) task1 = TTTask2(tasks[0].id, app_short_name=app.short_name) task2 = TTTask2(tasks[1].id, app_short_name=app.short_name) book_id = "BLBLB" data_mngr.record_book(dict(bookid=book_id, title=book_title, contributor="cont1", publisher="pub1", volume="1", img="image1")) task_run1 = dict(app_id=app.app_id, task_id=task1.task.id, info="[{\"id\":\"new\",\"top\":50,\"left\":9.5,\"width\":525,\"height\":626,\"text\":{\"titulo\":\"\",\"subtitulo\":\"\",\"assunto\":\"4\",\"fontes\":\"\",\"outros\":\"\",\"dataInicial\":\"\",\"dataFinal\":\"\",\"girar\":false,\"nao_girar\":true},\"editable\":true}]") task_run2 = dict(app_id=app.app_id, task_id=task1.task.id, info="[{\"id\":\"new\",\"top\":50,\"left\":15.5,\"width\":625,\"height\":626,\"text\":{\"titulo\":\"\",\"subtitulo\":\"\",\"assunto\":\"4\",\"fontes\":\"\",\"outros\":\"\",\"dataInicial\":\"\",\"dataFinal\":\"\",\"girar\":false,\"nao_girar\":true},\"editable\":true}]") # Anonymous submission submit_answer(self.base_url, task_run1) # FB authenticated user submission task_run2['facebook_user_id'] = '12345' submit_answer(self.base_url, task_run2) time.sleep(2) self.assertFalse(task1.check_answer()) task1.add_next_task() assert False except Meb_exception_tt2 as e: self.assertEquals(e.code, 3) finally: next_app = None next_app_list = pbclient.find_app(short_name=app.short_name[:-1] + "3") if len(next_app_list) > 0: next_app = next_app_list[0] next_task = None tasks = pbclient.get_tasks(next_app.id) for t in tasks: if t.info["page"] == task1.task.info["page"]: pbclient.delete_task(task_id=t.id) pbclient.delete_app(app_id=next_app.id) pbclient.delete_task(task1.task.id) pbclient.delete_task(task2.task.id) pbclient.delete_app(app.app_id) data_mngr.delete_book(book_id="BLBLB")
def __init__(self, **keyargs): if "short_name" in keyargs.keys(): if "_tt1" in keyargs['short_name']: short_name = keyargs['short_name'] else: logger.error(Meb_ttapps_exception(5, -1, "-")) raise Meb_ttapps_exception(5, -1, "-") else: logger.error(Meb_ttapps_exception(1, -1, "-")) raise Meb_ttapps_exception(1, -1, "-") if "title" in keyargs.keys(): title = keyargs['title'] + " " else: title = "" if keyargs.has_key("book_info"): data_mngr.record_book(keyargs["book_info"]) app_name = title + unicode("Seleção", "utf-8") super(Apptt_select, self).__init__( app_name, short_name, "Por favor. Selecione as páginas com tabela.") super(Apptt_select, self).set_template(meb_util.set_url( urllib2.urlopen( urllib2.Request( flask_app.config['URL_TEMPLATES'] + "/templates" + "/template-select.html")), short_name)) super(Apptt_select, self).set_long_description(meb_util.set_url( urllib2.urlopen( urllib2.Request( flask_app.config['URL_TEMPLATES'] + "/templates" + "/long_description-select.html")), short_name)) super(Apptt_select, self).add_app_infos( dict(thumbnail=flask_app.config['URL_TEMPLATES'] + "/images" + "/long_description_selection.png")) logger.info("Create task type 1")
def add_book(info_book): data_mngr.record_book(info_book)