def test_set_selected_option__deselect_others(self): select = Select() option1 = select.create_option("L1", selected=True) option2 = select.create_option("L2") select.selected_option = option2 assert_false(option1.selected) assert_is(option2, select.selected_option)
def test_defaults(self): checkbox = Checkbox() assert_equal("checkbox", checkbox.type) assert_equal("", checkbox.name) assert_equal("", checkbox.value) assert_false(checkbox.checked) assert_equal('<input type="checkbox"/>', str(checkbox))
def test_set_selected_option__deselect_others(self): select = Select() option1 = select.create_option("L1", selected=True) option2 = select.create_option("L2") select.selected_option = option2 assert_false(option1.selected) assert_is(option2, select.selected_option)
def test_defaults(self): radio = RadioButton() assert_equal("radio", radio.type) assert_equal("", radio.name) assert_equal("", radio.value) assert_false(radio.checked) assert_equal('<input type="radio"/>', str(radio))
def test_defaults(self): radio = RadioButton() assert_equal("radio", radio.type) assert_equal("", radio.name) assert_equal("", radio.value) assert_false(radio.checked) assert_equal('<input type="radio"/>', str(radio))
def test_defaults(self): checkbox = Checkbox() assert_equal("checkbox", checkbox.type) assert_equal("", checkbox.name) assert_equal("", checkbox.value) assert_false(checkbox.checked) assert_equal('<input type="checkbox"/>', str(checkbox))
def test_has_css_class(self): element = Element("div") element.add_css_classes("foo") assert_false(element.has_css_class("bar")) element.add_css_classes("bar") assert_true(element.has_css_class("bar")) element.remove_css_classes("bar") assert_false(element.has_css_class("bar"))
def test_has_css_class(self): element = Element("div") element.add_css_classes("foo") assert_false(element.has_css_class("bar")) element.add_css_classes("bar") assert_true(element.has_css_class("bar")) element.remove_css_classes("bar") assert_false(element.has_css_class("bar"))
def __call__(self, status: str, headers: Iterable[Header], exc_info: Any = None) -> StartResponseReturnType: assert_false(self.was_called, "start_response() called twice") assert_regex(status, _status_re) self.was_called = True self.status = status self.headers = list(headers) return lambda s: None
def check_source_parameter_and_availability(context, parameter, value, status_code): """Check that the source parameter equals value.""" post_response = context.response.json() source = get_item(context, "source") assert_equal(sanitize_value(value), source["parameters"][parameter]) if status_code == "None": assert_false("availability" in post_response) else: assert_equal(status_code, str(post_response["availability"][0]["status_code"]))
def test_multipart(self): form = Form() assert_false(form.multipart) assert_equal("application/x-www-form-urlencoded", form.encryption_type) form.multipart = True assert_equal("multipart/form-data", form.encryption_type) form.multipart = False assert_equal("application/x-www-form-urlencoded", form.encryption_type) form.encryption_type = "multipart/form-data" assert_true(form.multipart) form.encryption_type = "application/x-www-form-urlencoded" assert_false(form.multipart)
def test_boolean(self): class MyElement(Element): attr = boolean_html_attribute("data-attr") element = MyElement("div") assert_false(element.attr) assert_equal("<div></div>", str(element)) element.attr = True assert_true(element.attr) assert_equal('<div data-attr="data-attr"></div>', str(element)) element.attr = False assert_false(element.attr) assert_equal('<div></div>', str(element))
def test_multipart(self): form = Form() assert_false(form.multipart) assert_equal("application/x-www-form-urlencoded", form.encryption_type) form.multipart = True assert_equal("multipart/form-data", form.encryption_type) form.multipart = False assert_equal("application/x-www-form-urlencoded", form.encryption_type) form.encryption_type = "multipart/form-data" assert_true(form.multipart) form.encryption_type = "application/x-www-form-urlencoded" assert_false(form.multipart)
def check_item_does_not_exist(context, item): """Check that the item does not exist.""" uuids = [] reports = context.get("reports") for report in reports["reports"]: uuids.append(report["report_uuid"]) uuids.extend(report["subjects"].keys()) for subject in report["subjects"].values(): uuids.extend(subject["metrics"].keys()) for metric in subject["metrics"].values(): uuids.extend(metric["sources"].keys()) assert_false(context.uuid[item] in uuids)
def test_boolean(self): class MyElement(Element): attr = boolean_html_attribute("data-attr") element = MyElement("div") assert_false(element.attr) assert_equal("<div></div>", str(element)) element.attr = True assert_true(element.attr) assert_equal('<div data-attr="data-attr"></div>', str(element)) element.attr = False assert_false(element.attr) assert_equal('<div></div>', str(element))
def start_response_called_multiple_times_with_exc_info(self) -> None: assert_raised = False def app(_: WSGIEnvironment, sr: StartResponse) -> Iterable[bytes]: nonlocal assert_raised sr("200 OK", []) try: sr("404 Not Found", [], _get_exc_info()) except AssertionError: assert_raised = True return [] request = create_request("GET", "/foo/bar") run_wsgi_test(app, request) assert_false(assert_raised)
def test_css_class(self): class MyElement(Element): attr = css_class_attribute("my-class") element = MyElement("div") assert_false(element.attr) element.add_css_classes("other-class") assert_false(element.attr) element.add_css_classes("my-class") assert_true(element.attr) element.attr = False assert_false(element.has_css_class("my-class")) element.attr = False assert_false(element.has_css_class("my-class")) element.attr = True assert_true(element.has_css_class("my-class")) element.attr = True assert_true(element.has_css_class("my-class"))
def test_css_class(self): class MyElement(Element): attr = css_class_attribute("my-class") element = MyElement("div") assert_false(element.attr) element.add_css_classes("other-class") assert_false(element.attr) element.add_css_classes("my-class") assert_true(element.attr) element.attr = False assert_false(element.has_css_class("my-class")) element.attr = False assert_false(element.has_css_class("my-class")) element.attr = True assert_true(element.has_css_class("my-class")) element.attr = True assert_true(element.has_css_class("my-class"))
def test_default_value(self): option = Option("Test Label") assert_equal("Test Label", option.value) assert_equal("<option>Test Label</option>", str(option)) assert_false(option.selected) assert_false(option.disabled)
def test_default(self): group = OptionGroup("Test Label") assert_equal("Test Label", group.label) assert_false(group.disabled) assert_equal('<optgroup label="Test Label"></optgroup>', str(group))
def test_attributes(self): select = Select() assert_false(select.disabled)
def test_create_option__selected_deselect_others(self): select = Select() option = select.create_option("L1", selected=True) select.create_option("L2", selected=True) assert_false(option.selected)
def test_attributes(self): select = Select() select.autocomplete = "username" assert_false(select.disabled) assert_equal('<select autocomplete="username"></select>', str(select))
def test_string_filter__wrong_type(self) -> None: filter_ = parse_filter("foo.bar<='50'") assert_false(filter_({"foo": {"bar": 13}}))
def test_string_filter__gt(self) -> None: filter_ = parse_filter("foo.bar>'ABC'") assert_false(filter_({"foo": {"bar": "AAA"}})) assert_false(filter_({"foo": {"bar": "ABC"}})) assert_true(filter_({"foo": {"bar": "CAA"}}))
def test_no_such_field(self) -> None: f = parse_filter("foo<=10") assert_false(f({}))
def test_attributes(self): select = Select() assert_false(select.disabled)
def test_eq_date(self) -> None: f = parse_filter("foo=2016-03-24") assert_false(f({"foo": "2000-01-01"})) assert_true(f({"foo": "2016-03-24"}))
def test_wrong_type(self) -> None: f = parse_filter("foo<=10") assert_false(f({"foo": ""}))
def test_ge_int(self) -> None: f = parse_filter("foo>=10") assert_false(f({"foo": 9})) assert_true(f({"foo": 10})) assert_true(f({"foo": 11}))
def test_default_value(self): option = Option("Test Label") assert_equal("Test Label", option.value) assert_equal('<option>Test Label</option>', str(option)) assert_false(option.selected) assert_false(option.disabled)
def test_default(self): group = OptionGroup("Test Label") assert_equal("Test Label", group.label) assert_false(group.disabled) assert_equal('<optgroup label="Test Label"></optgroup>', str(group))
def check_invalid_credentials(context): """Check that the server responded that the credentials are invalid.""" assert_false(context.response.json()["ok"])
def test_create_option__selected_deselect_others(self): select = Select() option = select.create_option("L1", selected=True) select.create_option("L2", selected=True) assert_false(option.selected)
def test_eq_str(self) -> None: f = parse_filter("foo='bar'") assert_false(f({"foo": "baz"})) assert_true(f({"foo": "bar"}))
def test_string_filter__path_not_found(self) -> None: filter_ = parse_filter("foo.bar<='ABC'") assert_false(filter_({"foo": {}}))