Пример #1
0
    def test_bug_3(self):
        f = self.registry.fields[0]
        v = self.registry.fields[0].ops[0]
        value = 'foo'

        field = make_field(f, v, value)
        field_or = make_field(f, v, value, "lol")

        form = {'form_data': [None, field, field, field, field_or]}

        self.assertRaises(ParseError, self.registry.recreate_form, form)
Пример #2
0
    def test_bug_3(self):
        f = self.registry.fields[0]
        v = self.registry.fields[0].ops[0]
        value = 'foo'

        field = make_field(f, v, value)
        field_or = make_field(f, v, value, "lol")

        form = {'form_data': [None, field, field, field, field_or]}

        self.assertRaises(
            ParseError, self.registry.recreate_form, form)
Пример #3
0
def test_bug_2(multiseek_admin_page, initial_data):
    f = multiseek_admin_page.registry.fields[0]
    v = multiseek_admin_page.registry.fields[0].ops[0]
    value = 'foo'

    field = make_field(f, v, value, OR)

    form = [None, field,
            [OR, field, field, field],
            [OR, field, field, field]
            ]

    data = json.dumps({"form_data": form})

    user = User.objects.create(
        username='******', password='******')

    SearchForm.objects.create(
        name="bug-2",
        owner=user,
        public=True,
        data=data)
    multiseek_admin_page.load_form_by_name('bug-2')
    elements = multiseek_admin_page.browser.find_by_css(
        '[name=prev-op]:visible')
    for elem in elements:
        if elem.css("visibility") != 'hidden':
            assert elem.value == logic.OR
Пример #4
0
def test_load_form(multiseek_admin_page, initial_data):
    fld = make_field(
        multiseek_admin_page.registry.fields[2],
        multiseek_admin_page.registry.fields[2].ops[1],
        json.dumps([2000, 2010]))
    SearchForm.objects.create(
        name="lol",
        owner=User.objects.create(username='******', password='******'),
        public=True,
        data=json.dumps({"form_data": [None, fld]}))
    multiseek_admin_page.load_form_by_name('lol')

    field = multiseek_admin_page.extract_field_data(
        multiseek_admin_page.browser.find_by_id("field-0"))

    assert field['selected'] == text(
        multiseek_admin_page.registry.fields[2].label)
    assert field['value'][0] == 2000
    assert field['value'][1] == 2010

    # Przetestuj, czy po ANULOWANIU select wróci do pierwotnej wartości
    elem = multiseek_admin_page.browser.find_by_id("formsSelector").first
    elem.find_by_text('lol').click()
    multiseek_admin_page.dismiss_alert()

    elem = multiseek_admin_page.browser.find_by_id(
        "formsSelector").find_by_tag("option")
    assert elem[0].selected == True
Пример #5
0
def test_load_form(multiseek_admin_page):
    fld = make_field(multiseek_admin_page.registry.fields[2],
                     multiseek_admin_page.registry.fields[2].ops[1],
                     json.dumps([2000, 2010]))
    SearchForm.objects.create(name="lol",
                              owner=User.objects.create(username='******',
                                                        password='******'),
                              public=True,
                              data=json.dumps({"form_data": [None, fld]}))
    multiseek_admin_page.load_form_by_name('lol')

    field = multiseek_admin_page.extract_field_data(
        multiseek_admin_page.browser.find_by_id("field-0"))

    assert field['selected'] == unicode(
        multiseek_admin_page.registry.fields[2].label)
    assert field['value'][0] == 2000
    assert field['value'][1] == 2010

    # Przetestuj, czy po ANULOWANIU select wróci do pierwotnej wartości
    elem = multiseek_admin_page.browser.find_by_id("formsSelector").first
    elem.find_by_text('lol').click()
    multiseek_admin_page.dismiss_alert()

    elem = multiseek_admin_page.browser.find_by_id(
        "formsSelector").find_by_tag("option")
    assert elem[0].selected == True
Пример #6
0
    def test_bug_2(self):
        f = self.registry.fields[0]
        v = self.registry.fields[0].ops[0]
        value = 'foo'

        field = make_field(f, v, value, OR)

        form = [None, field,
                [OR, field, field, field],
                [OR, field, field, field]
        ]

        data = json.dumps({"form_data": form})

        user = User.objects.create(
            username='******', password='******')

        SearchForm.objects.create(
            name="bug-2",
            owner=user,
            public=True,
            data=data)
        self.page.load_form_by_name('bug-2')
        elements = self.page.find_elements_by_jquery(
            '[name=prev-op]:visible')
        for elem in elements:
            if elem.css("visibility") != 'hidden':
                self.assertEquals(elem.val(), logic.OR)
Пример #7
0
    def test_load_form(self):
        fld = make_field(
            self.registry.fields[2],
            self.registry.fields[2].ops[1],
            json.dumps([2000, 2010]))
        SearchForm.objects.create(
            name="lol",
            owner=User.objects.create(username='******', password='******'),
            public=True,
            data=json.dumps({"form_data": [None, fld]}))
        self.page.load_form_by_name('lol')

        field = self.page.extract_field_data(
            self.page.find_element_by_jquery("#field-0"))

        self.assertEquals(
            field['selected'], unicode(self.registry.fields[2].label))
        self.assertEquals(field['value'][0], 2000)
        self.assertEquals(field['value'][1], 2010)

        # Przetestuj, czy po ANULOWANIU select wróci do pierwotnej wartości
        select = Select(
            self.page.find_element_by_jquery("#formsSelector"))
        select.select_by_visible_text('lol')
        self.page.switch_to_alert().dismiss()

        self.assertEquals(
            self.page.find_element_by_jquery("#formsSelector").val(), "")
Пример #8
0
def test_autocomplete_field(multiseek_page):
    field = multiseek_page.get_field(FIELD)
    field['type'].find_by_value(unicode(multiseek_registry.AuthorQueryObject.label)).click()

    valueWidget = multiseek_page.browser.find_by_id("value")
    valueWidget.type('smit')
    valueWidget.type(Keys.ARROW_DOWN)
    valueWidget.type(Keys.RETURN)

    got = multiseek_page.serialize()
    expect = [None,
              make_field(
                      multiseek_registry.AuthorQueryObject,
                      unicode(EQUAL),
                      Author.objects.filter(last_name='Smith')[0].pk,
                      prev_op=None)]

    assert got == expect
Пример #9
0
    def test_autocomplete_field(self):
        field = self.page.get_field(FIELD)
        Select(field['type']).select_by_visible_text(
            unicode(multiseek_registry.AuthorQueryObject.label))

        valueWidget = self.page.find_element_by_id("value")
        valueWidget.send_keys('smit')
        valueWidget.send_keys(Keys.ARROW_DOWN)
        valueWidget.send_keys(Keys.RETURN)

        got = self.page.serialize()
        expect = [None,
                  make_field(
                      multiseek_registry.AuthorQueryObject,
                      unicode(EQUAL),
                      Author.objects.filter(last_name='Smith')[0].pk,
                      prev_op=None)]

        self.assertEquals(got, expect)
Пример #10
0
def test_bug_2(multiseek_admin_page):
    f = multiseek_admin_page.registry.fields[0]
    v = multiseek_admin_page.registry.fields[0].ops[0]
    value = 'foo'

    field = make_field(f, v, value, OR)

    form = [None, field, [OR, field, field, field], [OR, field, field, field]]

    data = json.dumps({"form_data": form})

    user = User.objects.create(username='******', password='******')

    SearchForm.objects.create(name="bug-2", owner=user, public=True, data=data)
    multiseek_admin_page.load_form_by_name('bug-2')
    elements = multiseek_admin_page.browser.find_by_css(
        '[name=prev-op]:visible')
    for elem in elements:
        if elem.css("visibility") != 'hidden':
            assert elem.value == logic.OR
Пример #11
0
def test_autocomplete_field(multiseek_page):
    field = multiseek_page.get_field(FIELD)
    field['type'].find_by_value(
        unicode(multiseek_registry.AuthorQueryObject.label)).click()

    valueWidget = multiseek_page.browser.find_by_id("value")
    valueWidget.type('smit')
    valueWidget.type(Keys.ARROW_DOWN)
    valueWidget.type(Keys.RETURN)

    got = multiseek_page.serialize()
    expect = [
        None,
        make_field(multiseek_registry.AuthorQueryObject,
                   unicode(EQUAL),
                   Author.objects.filter(last_name='Smith')[0].pk,
                   prev_op=None)
    ]

    assert got == expect
Пример #12
0
def test_autocomplete_field(multiseek_page):
    assert Language.objects.count()

    field = multiseek_page.get_field(FIELD)
    field['type'].find_by_value(
        text(multiseek_registry.AuthorQueryObject.label)).click()

    element = multiseek_page.browser.find_by_css(".select2-container")
    select_select2_autocomplete(
        multiseek_page.browser,
        element,
        "Smith")

    got = multiseek_page.serialize()
    expect = [None,
              make_field(
                  multiseek_registry.AuthorQueryObject,
                  text(EQUAL),
                  str(Author.objects.filter(last_name='Smith')[0].pk),
                  prev_op=None)]

    assert got == expect