예제 #1
0
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
예제 #2
0
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
예제 #3
0
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()
예제 #4
0
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"
예제 #5
0
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"
예제 #6
0
def test_can_create_page_component_from_page_component(page_component):
    # When
    actual = PageComponent.create(component=page_component)
    # Then
    assert actual == page_component