def show_list_of_arguments(context, argument_type, arguments): # pylint: disable=unused-argument """Check the arguments.""" if "..." in arguments: arguments = arguments.strip(".") assert_true(context.next_action().startswith(arguments)) else: assert_equal(arguments, context.next_action().strip())
def test_create_option__option_object(self): select = Select() option = select.create_option("Option Label", "test-value", selected=True) assert_equal("option", option.element_name) assert_equal("test-value", option.value) assert_true(option.selected)
def test_checked(self): checkbox = Checkbox() checkbox.checked = True assert_true(checkbox.checked) assert_equal( '<input checked="checked" type="checkbox"/>', str(checkbox) )
def test_set_selected_option(self): select = Select() select.create_option("L1") option = select.create_option("L2") select.create_option("L3") select.selected_option = option assert_true(option.selected) assert_is(option, select.selected_option)
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_create_option__option_object(self): select = Select() option = select.create_option( "Option Label", "test-value", selected=True ) assert_equal("option", option.element_name) assert_equal("test-value", option.value) assert_true(option.selected)
def test_set_selected_value(self): select = Select() select.create_option("L1", "v1") option = select.create_option("L2", "v2") select.create_option("L3", "v3") select.selected_value = "v2" assert_equal("v2", select.selected_value) assert_is(option, select.selected_option) assert_true(option.selected)
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 start_response_called_multiple_times(self) -> None: assert_raised = False def app(_: WSGIEnvironment, sr: StartResponse) -> Iterable[bytes]: nonlocal assert_raised sr("200 OK", []) try: sr("404 Not Found", []) except AssertionError: assert_raised = True return [] request = create_request("GET", "/foo/bar") run_wsgi_test(app, request) assert_true(assert_raised)
def run_app(self) -> None: app_run = False env: WSGIEnvironment | None = None def app( environ: WSGIEnvironment, sr: StartResponse ) -> Iterable[bytes]: nonlocal app_run, env app_run = True env = environ sr("200 OK", []) return [] request = create_request("GET", "/foo/bar") request.add_argument("foo", "bar") run_wsgi_test(app, request) assert_true(app_run, "app not run") assert env is not None assert_equal("foo=bar", env.get("QUERY_STRING"))
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_checked(self): radio = RadioButton() radio.checked = True assert_true(radio.checked) assert_equal('<input checked="checked" type="radio"/>', str(radio))
def test_true(self): assert_true(Element("div"))
def check_data_model(context): """Check the data model.""" assert_true("timestamp" in context.response.json())
def show_next_not_at_contexts(context, contexts): """Check that the next action doesn't have the excluded contexts.""" contexts = contexts.split(" and not at ") assert_true(all([f"@{c}" not in context.next_action() for c in contexts]))
def test_create_columns_with_classes(self): group = ColumnGroup() cols = group.create_columns_with_classes("cls1", "cls2") assert_equal(2, len(cols)) assert_true(cols[0].has_css_class("cls1"))
def show_next_action_at_home(context, projects): """Check that the next action doesn't have the excluded projects.""" projects = projects.split(" and not for ") assert_true(all([f"+{p}" not in context.next_action() for p in projects]))
def labels(): assert_true(portlet()) return dict((label.text, label_color(label)) for label in portlet().css('.labelListing .labelColor .labelTitle'))
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_nested_value(self) -> None: f = parse_filter("foo.bar<=10") assert_true(f({"foo": {"bar": 10}}))
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_eq_str(self) -> None: f = parse_filter("foo='bar'") assert_false(f({"foo": "baz"})) assert_true(f({"foo": "bar"}))
def active_labels(): assert_true(portlet(), 'labeling portlet is not visible') return portlet().css('.activeLabels .labelItem').text
def check_metrics(context): """Check that the metric needs to be measured.""" assert_true(context.uuid["metric"] in context.response.json().keys())
def my_test(self) -> None: assert_true(hasattr(self, "_my_before1"), "before1 not called") assert_true(hasattr(self, "_my_before2"), "before2 not called")
def test_checked(self): radio = RadioButton() radio.checked = True assert_true(radio.checked) assert_equal( '<input checked="checked" type="radio"/>', str(radio))
def assert_was_called(self) -> None: assert_true(self.was_called, "start_response() was not called")
def test_checked(self): checkbox = Checkbox() checkbox.checked = True assert_true(checkbox.checked) assert_equal( '<input checked="checked" type="checkbox"/>', str(checkbox))
def verifyText(locator, data): str = driver.find_element_by_id(locator).text assert_true(True, data)
def show_next_action_for_projects(context, projects): """Check that the next action has the required projects.""" projects = projects.split(" or for ") assert_true(any([f"+{p}" in context.next_action() for p in projects]))
def labels(): assert_true(portlet()) return dict( (label.text, label_color(label)) for label in portlet().css('.labelListing .labelColor .labelTitle'))
def check_container_contains_item(context, container, item): """Check that the container contains the item.""" assert_true( context.uuid[item] in get_container(context, container)[f"{item}s"])
def check_tag_report(context, tag): """Check that the tag report has the expected contents.""" for subject in context.tag_report["subjects"].values(): for metric in subject["metrics"].values(): assert_true(tag in metric["tags"])
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 form(): node = portlet().css('.updateLabeling').first_or_none assert_true(node, 'The updateLabeling form is missing.') return node