コード例 #1
0
    def test_clickables(self):
        clickable1 = Clickable("click",
                               "a",
                               "body/div/div/a",
                               id="Test1",
                               html_class="Test2",
                               clickable_depth=243,
                               function_id="Test3")
        self.database._insert_clickable_into_db(SESSION, WEBPAGE_ID,
                                                clickable1)

        clickables = self.database.get_all_clickables_to_page_id_from_db(
            SESSION, WEBPAGE_ID)
        self.assertEqual(len(clickables), 1)
        self.assertEqual(clickable1, clickables[0])

        self.database.set_clickable_clicked(
            SESSION,
            WEBPAGE_ID,
            clickable1.dom_address,
            clickable1.event,
            clickable_depth=243,
            clickable_type=ClickableType.CreatesNewNavigatables)

        clickables = self.database.get_all_clickables_to_page_id_from_db(
            SESSION, WEBPAGE_ID)
        self.assertEqual(len(clickables), 1)
        clickable1.clicked = True
        clickable1.clickable_type = ClickableType.CreatesNewNavigatables
        self.assertEqual(clickable1, clickables[0])
コード例 #2
0
ファイル: database.py プロジェクト: ConstantinT/jAEk
 def _parse_clickable_from_db_to_model(self, clickable):
     c = Clickable(clickable['event'], clickable['tag'], clickable['dom_address'], clickable['html_id'], clickable['html_class'], clickable['clickable_depth'], clickable['function_id'])
     c.clicked = clickable['clicked']
     c.clickable_type = self._num_to_clickable_type(clickable['clickable_type'])
     c.links_to = clickable['links_to']
     c.clickable_depth = clickable['clickable_depth']
     return c
コード例 #3
0
ファイル: database.py プロジェクト: ConstantinT/jAEk
 def get_all_clickables_to_page_id_from_db(self, current_session, page_id):
     clickables = self.clickables.find({"web_page_id": page_id, "session": current_session})
     result = []
     for clickable in clickables:
         c = Clickable(clickable['event'], clickable['tag'], clickable['dom_address'], clickable['html_id'], clickable['html_class'], clickable_depth=clickable['clickable_depth'], function_id=clickable['function_id'])
         c.links_to = clickable['links_to']
         c.clickable_type = self._num_to_clickable_type(clickable['clickable_type'])
         c.clicked = clickable['clicked']
         result.append(c)
     return result
コード例 #4
0
 def _parse_clickable_from_db_to_model(self, clickable):
     c = Clickable(clickable['event'], clickable['tag'],
                   clickable['dom_address'], clickable['html_id'],
                   clickable['html_class'], clickable['clickable_depth'],
                   clickable['function_id'])
     c.clicked = clickable['clicked']
     c.clickable_type = self._num_to_clickable_type(
         clickable['clickable_type'])
     c.links_to = clickable['links_to']
     c.clickable_depth = clickable['clickable_depth']
     return c
コード例 #5
0
 def get_all_clickables_to_page_id_from_db(self, current_session, page_id):
     clickables = self.clickables.find({
         "web_page_id": page_id,
         "session": current_session
     })
     result = []
     for clickable in clickables:
         c = Clickable(clickable['event'],
                       clickable['tag'],
                       clickable['dom_address'],
                       clickable['html_id'],
                       clickable['html_class'],
                       clickable_depth=clickable['clickable_depth'],
                       function_id=clickable['function_id'])
         c.links_to = clickable['links_to']
         c.clickable_type = self._num_to_clickable_type(
             clickable['clickable_type'])
         c.clicked = clickable['clicked']
         result.append(c)
     return result