def test_can_create_page_component_from_string(): component = "A" # When actual = PageComponent.create(component=component) # Then assert isinstance(actual, PageComponent) assert actual.main == component
def test_can_create_page_component_from_instance_of_page_component_subclass(): # Given class MyClass(PageComponent): pass component = MyClass() # When actual = PageComponent.create(component=component) # Then assert actual == component
def test_can_create_page_component_from_callable(): # Given def my_func(): return "A" component = my_func # When actual = PageComponent.create(component=component) # Then assert isinstance(actual, PageComponent) assert actual.main == my_func()
def test_can_create_page_component_from_instance_with_main_and_sidebar(): # Given class MyClass: @staticmethod def main(): return "A" @staticmethod def sidebar(): return "B" component = MyClass() # When actual = PageComponent.create(component=component) # Then assert isinstance(actual, PageComponent) assert actual.main == "A" assert actual.sidebar == "B"
def test_can_create_page_component_from_class_with_main_and_sidebar(): # Given class MyClass: # pylint: disable=too-few-public-methods @staticmethod def main(): return "A" @staticmethod def sidebar(): return "B" component = MyClass # When actual = PageComponent.create(component=component) # Then assert isinstance(actual, PageComponent) assert actual.main == "A" assert actual.sidebar == "B"
def test_can_create_page_component_from_page_component(page_component): # When actual = PageComponent.create(component=page_component) # Then assert actual == page_component