コード例 #1
0
    def test_new(self):

        browser.open(
            "/en/cms/content/new/"
            "?item_type=woost.tests.test_selenium.test_edit.EditTestModel")
        admin_login()

        assert not browser.is_element_present(
            "css=.part_field .control .select")
        assert not browser.is_element_present("css=.part_field .control .edit")
        assert not browser.is_element_present(
            "css=.part_field .control .delete")
        assert not browser.is_element_present(
            "css=.part_field .control .unlink")

        browser.click("css=.part_field .control .new")
        browser.wait_for_page_to_load(10000)

        browser.type("edited_item_description", "Foo")
        browser.click("css=.save_action")
        browser.wait_for_page_to_load(10000)

        datastore.sync()
        part_id = int(browser.get_value("edited_item_part"))
        assert EditTestModel.require_instance(part_id).description == "Foo"
コード例 #2
0
ファイル: test_search.py プロジェクト: marticongost/woost
 def test_unfold_expanded_search(self):
     browser.open("/en/cms/content/?content_view=flat")
     admin_login()
     browser.click("css=.advanced_search")
     browser.wait_for_page_to_load(10000)
     assert browser.is_element_present("css=.filters")
     assert browser.is_element_present("css=.filters .new_filter_selector")
コード例 #3
0
    def test_unlink(self):

        template = list(Template.select())[0]

        publishable = Publishable()
        publishable.set("enabled", True, "en")
        publishable.template = template
        publishable.insert()
        datastore.commit()

        browser.open("/en/cms/content/%d/fields" % publishable.id)
        admin_login()

        assert not browser.is_element_present(
            "css=.template_field .control .new")

        assert not browser.is_element_present(
            "css=.template_field .control .delete")

        browser.click("css=.template_field .control .unlink")
        browser.wait_for_page_to_load(10000)

        val = browser.get_value("edited_item_template")

        assert not browser.get_value("edited_item_template")
コード例 #4
0
    def test_delete(self):

        datastore.sync()
        container = EditTestModel()
        container.description = "test_edit container"

        part = EditTestModel()
        part.description = "test_edit part"
        container.part = part

        container.insert()
        datastore.commit()

        browser.open("/en/cms/content/%d/fields" % container.id)
        admin_login()

        assert not browser.is_element_present(
            "css=.part_field .control .select")
        assert not browser.is_element_present("css=.part_field .control .new")
        assert not browser.is_element_present(
            "css=.part_field .control .unlink")

        location = browser.get_location()
        browser.click("css=.part_field .control .delete")
        browser.wait_for_page_to_load(10000)
        assert browser.get_location() == location
        assert not browser.get_value("edited_item_part")

        datastore.sync()
        assert EditTestModel.get_instance(part.id) is part

        browser.click("css=.save_action")
        browser.wait_for_page_to_load(10000)
        datastore.sync()
        assert EditTestModel.get_instance(part.id) is None
コード例 #5
0
ファイル: test_search.py プロジェクト: marticongost/woost
    def test_multiple_options(self):

        from woost.models import User, Role
        from cocktail.controllers.userfilter import MultipleChoiceFilter

        administrators = Role.require_instance(qname="woost.administrators")

        anonymous = Role.require_instance(qname="woost.anonymous")

        with override(User.roles, user_filter=MultipleChoiceFilter):

            browser.open(
                "/en/cms/content/?content_view=flat&type=woost.models.user.User&search_expanded=true"
            )
            admin_login()

            # Select the filter
            browser.fire_event("css=.new_filter_selector", "click")
            browser.fire_event("css=.new_filter-member-roles", "click")

            # Select options
            browser.fire_event("css=.filters .values_field .select", "click")
            assert browser.is_visible("css=.modal_selector_dialog")

            for role in (administrators, anonymous):
                browser.click("css=.modal_selector_dialog input[value=%d]" %
                              role.id)

            browser.fire_event("css=.modal_selector_dialog .accept", "click")

            for role in (administrators, anonymous):
                assert browser.is_element_present(
                    "css=.filters .values_field input[value=%d]" % role.id)

            browser.click("css=.filters .search_button")
            browser.wait_for_page_to_load(10000)

            # Validate results
            results_count = len(administrators.users) + len(anonymous.users)
            rows_count = browser.jquery_count(".collection_display .item_row")
            assert rows_count == results_count

            # Make sure the search control preserves its state
            for role in (administrators, anonymous):
                assert browser.is_element_present(
                    "css=.filters .values_field input[value=%d]" % role.id)

            browser.fire_event("css=.filters .values_field .select", "click")

            for role in (administrators, anonymous):
                assert browser.is_checked(
                    "css=.modal_selector_dialog input[value=%d]" % role.id)
コード例 #6
0
    def test_select(self):

        template = list(Template.select())[0]

        browser.open(
            "/en/cms/content/new/?item_type=woost.models.publishable.Publishable"
        )
        admin_login()

        assert not browser.is_element_present(
            "css=.template_field .control .new")

        assert not browser.is_element_present(
            "css=.template_field .control .unlink")

        assert not browser.is_element_present(
            "css=.template_field .control .delete")

        browser.click("css=.template_field .control .select")
        browser.wait_for_page_to_load(10000)

        assert browser.is_visible("css=.collection_display #%d" % template.id)
        browser.click("css=.collection_display #%d" % template.id)
        browser.click("css=.ContentView .select_action")
        browser.wait_for_page_to_load(10000)

        assert translations(template, "en") \
            in browser.jquery_html(".template_field .control")

        assert browser.get_value("edited_item_template") == str(template.id)
コード例 #7
0
ファイル: test_search.py プロジェクト: marticongost/woost
    def test_add_filters_from_selector(self):

        from cocktail.schema.expressions import Self
        from cocktail.persistence import Query

        results = Item.select(
            [Item.id.greater(15),
             Self.search("@localhost", languages=["en"])])
        results_count = len(results)

        browser.open("/en/cms/content/?content_view=flat&search_expanded=true"
                     "&page_size=%d" % (results_count + 1))
        admin_login()

        # Add filters
        for i, filter_id in enumerate(("member-id", "global_search")):
            browser.fire_event("css=.new_filter_selector", "click")
            browser.fire_event("css=.new_filter-%s" % filter_id, "click")

        assert browser.jquery_count(".filters .filter_list .filter_entry") == 2

        # Set values on filters
        browser.type("filter_operator0", "gt")
        browser.type("filter_value0", "15")
        browser.type("filter_value1", "@localhost")
        browser.click("css=.filters .search_button")
        browser.wait_for_page_to_load(10000)

        # Test the returned content
        rows_count = browser.jquery_count(".collection_display .item_row")
        assert rows_count == results_count

        # Supplied values must be preserved between page loads
        assert browser.get_selected_value("filter_operator0") == "gt"
        assert browser.get_value("filter_value0") == "15"
        assert browser.get_value("filter_value1") == "@localhost"
コード例 #8
0
ファイル: test_search.py プロジェクト: marticongost/woost
    def test_item_selector(self):

        from woost.models import Publishable, Template
        template = list(Template.select())[0]

        browser.open(
            "/en/cms/content/?content_view=flat&type=woost.models.publishable.Publishable&search_expanded=true"
        )
        admin_login()

        browser.fire_event("css=.new_filter_selector", "click")
        browser.fire_event("css=.new_filter-member-template", "click")
        assert not browser.is_element_present("css=.filters .value_field .new")
        assert not browser.is_element_present(
            "css=.filters .value_field .edit")
        assert not browser.is_element_present(
            "css=.filters .value_field .delete")
        assert not browser.is_element_present(
            "css=.filters .value_field .unlink")
        browser.click("css=.filters .value_field .select")

        browser.select_frame(
            "dom=selenium.browserbot.getCurrentWindow().frames[0]")
        browser.wait_for_element_present("css=.collection_display", 10000)
        assert not browser.is_element_present("css=.new_action")
        browser.click("css=.collection_display #%d" % template.id)
        browser.click("css=.select_action")

        browser.select_frame("relative=parent")
        browser.wait_for_element_present("css=.collection_display", 10000)

        assert translations(template, "en") \
            in browser.jquery_html(".filters .value_field")

        assert browser.get_value("filter_value0") == str(template.id)

        browser.click("css=.filters .search_button")
        browser.wait_for_page_to_load(10000)

        rows_count = browser.jquery_count(".collection_display .item_row")
        assert rows_count == len(template.items)
コード例 #9
0
    def test_edit(self):

        datastore.sync()
        container = EditTestModel()
        container.description = "test_edit container"

        part = EditTestModel()
        part.description = "test_edit part"
        container.part = part

        container.insert()
        datastore.commit()

        browser.open("/en/cms/content/%d/fields" % container.id)
        admin_login()

        assert not browser.is_element_present(
            "css=.part_field .control .select")
        assert not browser.is_element_present("css=.part_field .control .new")
        assert not browser.is_element_present(
            "css=.part_field .control .unlink")
        assert browser.get_value("edited_item_part") == str(part.id)

        browser.click("css=.part_field .control .edit")
        browser.wait_for_page_to_load(10000)

        browser.type("edited_item_description", "modified test_edit part")
        browser.click("css=.save_action")
        browser.wait_for_page_to_load(10000)

        browser.click("css=.cancel_action")
        browser.wait_for_page_to_load(10000)

        datastore.sync()
        assert browser.get_value("edited_item_part") == str(part.id)
        assert part.description == "modified test_edit part"
コード例 #10
0
 def test_logout(self):
     browser.open("/en/cms")
     self.login(admin_email, admin_password)
     browser.click("css=.logout_button")
     browser.wait_for_page_to_load(5000)
     self.assert_login_form_visible()
コード例 #11
0
 def login(self, user_name="", password=""):
     browser.type("user", user_name)
     browser.type("password", password)
     browser.click("authenticate")
     browser.wait_for_page_to_load(10000)
コード例 #12
0
ファイル: __init__.py プロジェクト: marticongost/woost
def login(user, password):
    browser.type("user", user)
    browser.type("password", password)
    browser.click("authenticate")
    browser.wait_for_page_to_load(10000)