def _test_wiki_format(self, new_text, expected_text, action):
        """Test bolding wiki text.

        Args:
            
        """
        # Setup and get starting values
        orig_version, orig_text = self._edit_wiki_setup()
        
        # Enter text
        if new_text:
            util.add_wiki_text(self.driver, new_text)
        
        # Set text to boldface
        if action == 'bold':
            self.driver.execute_script(
                '$("#wmd-input").select();'
            )
        else:
            util.select_partial(self.driver, 'wmd-input', 2, len(expected_text) + 2)

        # Click bold button
        self.driver.find_element_by_id('wmd-bold-button').click()
        
        # Get appropriate wrap string and bold counter function
        if action == 'bold':
            expected_wrap = '**%s**' % expected_text
            strong_fun = lambda x: x > 0
        else:
            expected_wrap = expected_text
            strong_fun = lambda x: x == 0

        # Assert that wiki text has been wrapped in **
        self.assertEqual(
            util.get_wiki_input(self.driver).get_attribute('value'),
            expected_wrap
        )

        # Assert that there are <strong> elements in the preview
        preview_bold_elements = self.driver.find_elements_by_css_selector(
            '#wmd-preview strong'
        )
        self.assertTrue(strong_fun(len(preview_bold_elements)))

        # Submit and check results
        expected_version = orig_version + 1
        self._edit_wiki_teardown(expected_version, expected_text)

        # Assert that there are <strong> elements in the wiki text
        wiki_par = util.get_wiki_par(self.driver)
        bold_elements = wiki_par.find_elements_by_tag_name('strong')
        self.assertTrue(strong_fun(len(bold_elements)))
Example #2
0
    def _test_wiki_format(self, new_text, expected_text, action):
        """Test bolding wiki text.

        Args:
            
        """
        # Setup and get starting values
        orig_version, orig_text = self._edit_wiki_setup()
        
        # Enter text
        if new_text:
            util.add_wiki_text(self.driver, new_text)
        
        # Set text to boldface
        if action == 'bold':
            self.driver.execute_script(
                '$("#wmd-input").select();'
            )
        else:
            util.select_partial(self.driver, 'wmd-input', 2, len(expected_text) + 2)

        # Click bold button
        self.driver.find_element_by_id('wmd-bold-button').click()
        
        # Get appropriate wrap string and bold counter function
        if action == 'bold':
            expected_wrap = '**%s**' % expected_text
            strong_fun = lambda x: x > 0
        else:
            expected_wrap = expected_text
            strong_fun = lambda x: x == 0

        # Assert that wiki text has been wrapped in **
        self.assertEqual(
            util.get_wiki_input(self.driver).get_attribute('value'),
            expected_wrap
        )

        # Assert that there are <strong> elements in the preview
        preview_bold_elements = self.driver.find_elements_by_css_selector(
            '#wmd-preview strong'
        )
        self.assertTrue(strong_fun(len(preview_bold_elements)))

        # Submit and check results
        expected_version = orig_version + 1
        self._edit_wiki_teardown(expected_version, expected_text)

        # Assert that there are <strong> elements in the wiki text
        wiki_par = util.get_wiki_par(self.driver)
        bold_elements = wiki_par.find_elements_by_tag_name('strong')
        self.assertTrue(strong_fun(len(bold_elements)))
    def _test_wiki_edit(self, new_text):
        
        # Get original values and open edit box
        orig_version, orig_text = self._edit_wiki_setup()

        # Enter text
        util.add_wiki_text(self.driver, new_text)
        
        # Update expected version and text
        expected_version = orig_version + 1
        expected_text = orig_text + new_text
        
        # Submit changes and check results
        self._edit_wiki_teardown(expected_version, expected_text)
Example #4
0
    def _test_wiki_edit(self, new_text):
        
        # Get original values and open edit box
        orig_version, orig_text = self._edit_wiki_setup()

        # Enter text
        util.add_wiki_text(self.driver, new_text)
        
        # Update expected version and text
        expected_version = orig_version + 1
        expected_text = orig_text + new_text
        
        # Submit changes and check results
        self._edit_wiki_teardown(expected_version, expected_text)
    def test_node_wiki_changes_log(self):
        """
        test to make sure that project log works correctly on a node wiki change

        """
        # Browse to wiki page
        self.driver.find_element_by_link_text('Wiki').click()


         # Get original version number
        orig_version = util.get_wiki_version(self.driver)

        # edit the wiki
        util.edit_wiki(self.driver)
        util.clear_wiki_text(self.driver)
        util.add_wiki_text(self.driver, str(uuid.uuid1())[:20])
        util.submit_wiki_text(self.driver)

        #get wiki_url
        wiki_url = self.driver.current_url

        #get log
        util.goto_project(self.driver)
        message_log = self.get_log()

        #assert the time
        self._assert_time(message_log.log_time)

        #assert the log
        new_version = str(orig_version + 1)
        self.assertEqual(message_log.log_text, self.user_data["fullname"] + " updated wiki page home to version "
                                               + new_version)


        #check the user_url and node_url
        self.assertEqual(message_log.log_url[0], self.get_user_url())
        self.assertEqual(message_log.log_url[1], wiki_url)
Example #6
0
    def test_node_wiki_changes_log(self):
        """
        test to make sure that project log works correctly on a node wiki change

        """
        # Browse to wiki page
        self.driver.find_element_by_link_text('Wiki').click()

        # Get original version number
        orig_version = util.get_wiki_version(self.driver)

        # edit the wiki
        util.edit_wiki(self.driver)
        util.clear_wiki_text(self.driver)
        util.add_wiki_text(self.driver, str(uuid.uuid1())[:20])
        util.submit_wiki_text(self.driver)

        #get wiki_url
        wiki_url = self.driver.current_url

        #get log
        util.goto_project(self.driver)
        message_log = self.get_log()

        #assert the time
        self._assert_time(message_log.log_time)

        #assert the log
        new_version = str(orig_version + 1)
        self.assertEqual(
            message_log.log_text, self.user_data["fullname"] +
            " updated wiki page home to version " + new_version)

        #check the user_url and node_url
        self.assertEqual(message_log.log_url[0], self.get_user_url())
        self.assertEqual(message_log.log_url[1], wiki_url)
Example #7
0
 def _add_wiki(self,text):
     #help function to add the wiki "text"
     util.edit_wiki(self.driver)
     util.clear_wiki_text(self.driver)
     util.add_wiki_text(self.driver, text)
     util.submit_wiki_text(self.driver)
Example #8
0
 def _add_wiki(self, text):
     #help function to add the wiki "text"
     util.edit_wiki(self.driver)
     util.clear_wiki_text(self.driver)
     util.add_wiki_text(self.driver, text)
     util.submit_wiki_text(self.driver)