當前位置: 首頁>>代碼示例>>Python>>正文


Python AdvancedSettingsPage.wait_for_modal_load方法代碼示例

本文整理匯總了Python中common.test.acceptance.pages.studio.settings_advanced.AdvancedSettingsPage.wait_for_modal_load方法的典型用法代碼示例。如果您正苦於以下問題:Python AdvancedSettingsPage.wait_for_modal_load方法的具體用法?Python AdvancedSettingsPage.wait_for_modal_load怎麽用?Python AdvancedSettingsPage.wait_for_modal_load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common.test.acceptance.pages.studio.settings_advanced.AdvancedSettingsPage的用法示例。


在下文中一共展示了AdvancedSettingsPage.wait_for_modal_load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: AdvancedSettingsValidationTest

# 需要導入模塊: from common.test.acceptance.pages.studio.settings_advanced import AdvancedSettingsPage [as 別名]
# 或者: from common.test.acceptance.pages.studio.settings_advanced.AdvancedSettingsPage import wait_for_modal_load [as 別名]
class AdvancedSettingsValidationTest(StudioCourseTest):
    """
    Tests for validation feature in Studio's advanced settings tab
    """
    def setUp(self):
        super(AdvancedSettingsValidationTest, self).setUp()
        self.advanced_settings = AdvancedSettingsPage(
            self.browser,
            self.course_info['org'],
            self.course_info['number'],
            self.course_info['run']
        )

        self.type_fields = ['Course Display Name', 'Advanced Module List', 'Discussion Topic Mapping',
                            'Maximum Attempts', 'Course Announcement Date']

        # Before every test, make sure to visit the page first
        self.advanced_settings.visit()

    def test_modal_shows_one_validation_error(self):
        """
        Test that advanced settings don't save if there's a single wrong input,
        and that it shows the correct error message in the modal.
        """

        # Feed an integer value for String field.
        # .set method saves automatically after setting a value
        course_display_name = self.advanced_settings.get('Course Display Name')
        self.advanced_settings.set('Course Display Name', 1)
        self.advanced_settings.wait_for_modal_load()

        # Test Modal
        self.check_modal_shows_correct_contents(['Course Display Name'])
        self.advanced_settings.refresh_and_wait_for_load()

        self.assertEquals(
            self.advanced_settings.get('Course Display Name'),
            course_display_name,
            'Wrong input for Course Display Name must not change its value'
        )

    def test_modal_shows_multiple_validation_errors(self):
        """
        Test that advanced settings don't save with multiple wrong inputs
        """

        # Save original values and feed wrong inputs
        original_values_map = self.get_settings_fields_of_each_type()
        self.set_wrong_inputs_to_fields()
        self.advanced_settings.wait_for_modal_load()

        # Test Modal
        self.check_modal_shows_correct_contents(self.type_fields)
        self.advanced_settings.refresh_and_wait_for_load()

        for key, val in original_values_map.iteritems():
            self.assertEquals(
                self.advanced_settings.get(key),
                val,
                'Wrong input for Advanced Settings Fields must not change its value'
            )

    def test_undo_changes(self):
        """
        Test that undo changes button in the modal resets all settings changes
        """

        # Save original values and feed wrong inputs
        original_values_map = self.get_settings_fields_of_each_type()
        self.set_wrong_inputs_to_fields()

        # Let modal popup
        self.advanced_settings.wait_for_modal_load()

        # Click Undo Changes button
        self.advanced_settings.undo_changes_via_modal()

        # Check that changes are undone
        for key, val in original_values_map.iteritems():
            self.assertEquals(
                self.advanced_settings.get(key),
                val,
                'Undoing Should revert back to original value'
            )

    def test_manual_change(self):
        """
        Test that manual changes button in the modal keeps settings unchanged
        """
        inputs = {"Course Display Name": 1,
                  "Advanced Module List": 1,
                  "Discussion Topic Mapping": 1,
                  "Maximum Attempts": '"string"',
                  "Course Announcement Date": '"string"',
                  }

        self.set_wrong_inputs_to_fields()
        self.advanced_settings.wait_for_modal_load()
        self.advanced_settings.trigger_manual_changes()

#.........這裏部分代碼省略.........
開發者ID:AlexxNica,項目名稱:edx-platform,代碼行數:103,代碼來源:test_studio_settings.py

示例2: AdvancedSettingsValidationTest

# 需要導入模塊: from common.test.acceptance.pages.studio.settings_advanced import AdvancedSettingsPage [as 別名]
# 或者: from common.test.acceptance.pages.studio.settings_advanced.AdvancedSettingsPage import wait_for_modal_load [as 別名]

#.........這裏部分代碼省略.........

    def test_automatic_quoting_of_non_json_value(self):
        """
        Scenario: Test that advanced settings automatically quotes the field input
        upon saving
            Given I am on the Advanced Course Settings page in Studio
            When I create a non-JSON value not in quotes
                Then it is displayed as a string
        """

        self.advanced_settings.set(self.course_name_key, self.course_name_value)
        self.assertEqual(
            self.advanced_settings.get(self.course_name_key),
            '"Test Name"'
        )

    def test_validation_error_for_wrong_input_type(self):
        """
        Scenario: Test error if value supplied is of the wrong type
            Given I am on the Advanced Course Settings page in Studio
            When I create a JSON object as a value for "Course Display Name"
                Then I get an error on save
             And I reload the page
             Then the policy key value is unchanged
        """

        course_display_name = self.advanced_settings.get('Course Display Name')
        inputs = {
            "key": "value",
            "key_2": "value_2"
        }
        json_input = json.dumps(inputs)
        self.advanced_settings.set('Course Display Name', json_input)
        self.advanced_settings.wait_for_modal_load()
        self.check_modal_shows_correct_contents(['Course Display Name'])
        self.advanced_settings.refresh_and_wait_for_load()
        self.assertEquals(
            self.advanced_settings.get('Course Display Name'),
            course_display_name,
            'Wrong input for Course Display Name must not change its value'
        )

    def test_modal_shows_one_validation_error(self):
        """
        Test that advanced settings don't save if there's a single wrong input,
        and that it shows the correct error message in the modal.
        """

        # Feed an integer value for String field.
        # .set method saves automatically after setting a value
        course_display_name = self.advanced_settings.get('Course Display Name')
        self.advanced_settings.set('Course Display Name', 1)
        self.advanced_settings.wait_for_modal_load()

        # Test Modal
        self.check_modal_shows_correct_contents(['Course Display Name'])
        self.advanced_settings.refresh_and_wait_for_load()

        self.assertEquals(
            self.advanced_settings.get('Course Display Name'),
            course_display_name,
            'Wrong input for Course Display Name must not change its value'
        )

    def test_modal_shows_multiple_validation_errors(self):
        """
開發者ID:cmscom,項目名稱:edx-platform,代碼行數:70,代碼來源:test_studio_settings.py


注:本文中的common.test.acceptance.pages.studio.settings_advanced.AdvancedSettingsPage.wait_for_modal_load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。