Esempio n. 1
0
def rendering_when_not_allowed(fixture):
    """When not allowed to see the Widget, it is not rendered."""
    tester = WidgetTester(fixture.widget)

    fixture.field.access_rights.readable = Allowed(False)
    fixture.field.access_rights.writable = Allowed(False)
    actual = tester.render_html()
    if fixture.field_controls_visibility:
        vassert(actual == '')
    else:
        vassert(re.match(fixture.expected_html, actual))
Esempio n. 2
0
def test_rendering_when_not_allowed(input_scenarios):
    """When not allowed to see the Widget, it is not rendered."""
    fixture = input_scenarios

    tester = WidgetTester(fixture.widget)

    fixture.bound_field.access_rights.readable = Allowed(False)
    fixture.bound_field.access_rights.writable = Allowed(False)

    actual = tester.render_html()
    assert actual == ''
Esempio n. 3
0
def test_rendering_when_not_allowed(input_scenarios):
    """When not allowed to see the Widget, it is not rendered."""
    fixture = input_scenarios

    tester = WidgetTester(fixture.widget)

    fixture.field.access_rights.readable = Allowed(False)
    fixture.field.access_rights.writable = Allowed(False)
    actual = tester.render_html()
    if fixture.field_controls_visibility:
        assert actual == ''
    else:
        assert actual == fixture.expected_html
Esempio n. 4
0
    def tailored_access_make_inputs_security_sensitive(self, fixture):
        """An Input is sensitive if explicitly set as sensitive, or if its Fields has non-defaulted
           mechanisms for determiing access rights."""

        form = Form(fixture.view, 'some_form')
        field = Field(default=3, readable=Allowed(True))
        field.bind('field_name', EmptyStub())
        input_widget = TextInput(form, field)

        vassert(input_widget.is_security_sensitive)
 def fields(self, fields):
     fields.choice = ChoiceField([Choice(1, IntegerField(label='One')),
                                 Choice(2, IntegerField(label='Two')),
                                 Choice(3, IntegerField(label='Three'))],
                                 label='Choice')
     fields.choice2 = ChoiceField([Choice(4, IntegerField(label='Four')),
                                 Choice(5, IntegerField(label='Five')),
                                 Choice(6, IntegerField(label='Six'))],
                                 label='Choice2')
     fields.calculated_state = IntegerField(label='Calculated', writable=Allowed(False))
 def fields(self, fields):
     fields.choice = ChoiceField([Choice(1, IntegerField(label='One')),
                                 Choice(2, IntegerField(label='Two')),
                                 Choice(3, IntegerField(label='Three'))],
                                 label='Choice')
     fields.choice3 = ChoiceField([Choice(7, IntegerField(label='Seven')),
                                 Choice(8, IntegerField(label='Eight')),
                                 Choice(9, IntegerField(label='Nine'))],
                                 label='Choice3')
     fields.calculated_state = IntegerField(label='Calculated', writable=Allowed(False))
Esempio n. 7
0
def test_choices_disabled(web_fixture, checkbox_fixture, choice_type_scenario):
    """A choice that is not writable renders as disabled."""

    fixture = checkbox_fixture
    choices = [Choice(1, IntegerField(label='One')),
               Choice(2, IntegerField(label='Two', writable=Allowed(False)))]
    fixture.field = MultiChoiceField(choices)

    model_object = fixture.model_object
    model_object.an_attribute = [1]
    wsgi_app = web_fixture.new_wsgi_app(child_factory=fixture.new_Form(input_widget_class=choice_type_scenario.input_type).factory('myform'))
    web_fixture.reahl_server.set_app(wsgi_app)
    web_fixture.driver_browser.open('/')

    assert web_fixture.driver_browser.is_element_enabled(choice_type_scenario.xpath_function_to_choice('One'))
    assert not web_fixture.driver_browser.is_element_enabled(choice_type_scenario.xpath_function_to_choice('Two'))
Esempio n. 8
0
 def events(self, events):
     events.an_event = Event(label='click me', writable=Allowed(False),
                             disallowed_message='you cannot do this')
Esempio n. 9
0
 def fields(self, fields):
     fields.field_name = Field(default='abc', writable=Allowed(False), disallowed_message='you are not allowed to write this')
Esempio n. 10
0
    def nothing_allowed_on_button(self):
        self.readable = Allowed(False)
        self.writable = Allowed(False)
        self.input_widget = ButtonInput(self.form, self.event)

        self.expected_html = ''
Esempio n. 11
0
    def buttons_must_be_readable_to_be_present(self):
        self.readable = Allowed(False)
        self.writable = Allowed(True)
        self.input_widget = ButtonInput(self.form, self.event)

        self.expected_html = ''
Esempio n. 12
0
    def greyed_button_rendering(self):
        self.readable = Allowed(True)
        self.writable = Allowed(False)
        self.input_widget = ButtonInput(self.form, self.event)

        self.expected_html = '<input name="event.some_form-event_name?" id="id-event-46-some_form-event_name-63-" disabled="disabled" form="some_form" type="submit" value="event_name" class="reahl-primitiveinput">'
Esempio n. 13
0
    def empty_rendering(self):
        self.readable = Allowed(False)
        self.writable = Allowed(False)
        self.input_widget = TextInput(self.form, self.field)

        self.expected_html = ''
Esempio n. 14
0
    def valueless_rendering(self):
        self.readable = Allowed(False)
        self.writable = Allowed(True)
        self.input_widget = TextInput(self.form, self.field)

        self.expected_html = '<input name="some_form-field_name" id="id-some_form-field_name" form="some_form" type="text" value="" class="reahl-primitiveinput reahl-textinput">'
Esempio n. 15
0
 def fields(self, fields):
     fields.choice = ChoiceField([Choice(1, IntegerField(label='One')),
                                 Choice(2, IntegerField(label='Two')),
                                 Choice(3, IntegerField(label='Three'))],
                                 label='Choice')
     fields.calculated_state = IntegerField(label='Calculated', writable=Allowed(not fixture.read_only))
Esempio n. 16
0
        def disabled_rendering(self):
            self.readable = Allowed(True)
            self.writable = Allowed(False)
            self.input_widget = TextInput(self.form, self.field)

            self.expected_html = '<input name="field_name" disabled="disabled" form="some_form" type="text" value="3" class="reahl-textinput">'
Esempio n. 17
0
        def greyed_button_rendering(self):
            self.readable = Allowed(True)
            self.writable = Allowed(False)
            self.input_widget = ButtonInput(self.form, self.event)

            self.expected_html = '<input name="event.event_name?" disabled="disabled" form="some_form" type="submit" value="event_name">'