def test_05_mbdb_loading(self):
     # Creating new tt applications
     create_tt_apps(self.app, self.book_id)
     app_t1 = pbclient.find_app(short_name=self.book_id + "_tt1")
     self.assertTrue(len(app_t1) > 0, "Error tt_app was not created")
     
     # check if the book was created
     self.assertTrue(get_book(self.book_id))
     
     # check if the workflow transaction (T1) was created
     task_t1 = pbclient.get_tasks(app_t1[0].id, sys.maxint)[0]
     self.assertTrue(len(get_workflow_transaction()) == 74)
     
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=None, task_id_3=None, task_id_4=None)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     
     task_t2 = create_t2_task(self, self.book_id, task_t1)
     
     # check if the workflow transaction (T2) was created
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=task_t2.id, task_id_3=None, task_id_4=None)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     
     # check if the page was created
     page = get_page(self.book_id, task_t2.info['page'])
     self.assertTrue(page)
     
     tasks_t3 = create_t3_task(self, self.book_id, task_t2)
     
     # check if the workflow transactions (T3) were created
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=task_t2.id, task_id_3=tasks_t3[0].id, task_id_4=None)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=task_t2.id, task_id_3=tasks_t3[1].id, task_id_4=None)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     
     # check if the page tables were created
     page_tables = get_page_table(self.book_id, page.id)
     self.assertTrue(len(page_tables) == 2)
     
     # check if the metadata was created
     self.assertTrue(get_metadata(page_tables[0].id))
     self.assertTrue(get_metadata(page_tables[1].id))
     
     tasks_t4 = create_t4_task(self, self.book_id, tasks_t3[0], 1)
     close_t4_task(self, self.book_id, tasks_t4[0])
     
     # check if the workflow transactions (T4) were created
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=task_t2.id, task_id_3=tasks_t3[0].id, task_id_4=tasks_t4[0].id)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     
     tasks_t4 = create_t4_task(self, self.book_id, tasks_t3[1], 2)
     close_t4_task(self, self.book_id, tasks_t4[1])
     
     # check if the workflow transactions (T4) were created
     workflow_transaction_info = dict(task_id_1=task_t1.id, task_id_2=task_t2.id, task_id_3=tasks_t3[1].id, task_id_4=tasks_t4[1].id)
     self.assertTrue(get_workflow_transaction(workflow_transaction_info))
     
     # check if the cells were created
     self.assertTrue(len(get_cell(page_tables[0].id)) == 6)
     self.assertTrue(len(get_cell(page_tables[1].id)) == 6)
 def test_01_t2_creation(self):
     # Creating new tt applications
     create_tt_apps(self.app, self.book_id)
     app_t1 = pbclient.find_app(short_name=self.book_id + "_tt1")
     self.assertTrue(len(app_t1) > 0, "Error tt_app was not created")
     task_t1 = pbclient.get_tasks(app_t1[0].id, sys.maxint)[0]
     
     create_t2_task(self, self.book_id, task_t1)
    def test_02_init(self):
        # Creating new tt applications
        create_tt_apps(self.app, "rpparaiba1918")
        pb_app = pbclient.find_app(short_name="rpparaiba1918_tt1")

        # application is already created
        n_app_tasks = len(pbclient.get_tasks(pb_app[0].id, sys.maxint))
        rv = self.app.get("/api/rpparaiba1918/init")

        self.assertTrue(rv.data, "Error tt_app was not created")

        # if application is already created init cant duplicate the tasks
        self.assertEqual(n_app_tasks, len(pbclient.get_tasks(pb_app[0].id, sys.maxint)), "Error duplicated tasks")
    def test_03_init(self):
        # Creating tt_app where book_id does not exist
        inexistent_id = "XX_does_not_exist_XX"
        init_req = create_tt_apps(self.app, inexistent_id)

        self.assertEqual(init_req.data, "False", "Error application can not be created")

        search_list = pbclient.find_app(short_name=inexistent_id + "_tt1")

        self.assertTrue(len(search_list) == 0, "Error application with inexistent id was found")
 def test_01_init(self):
     # Creating new tt applications
     create_tt_apps(self.app, "rpparaiba1918")
     pb_app = pbclient.find_app(short_name="rpparaiba1918_tt1")
     self.assertTrue(len(pb_app) > 0, "Error tt_app was not created")