예제 #1
0
def test_StepDict_can_load_steps_from_an_object():
    """
    aloe.STEP_REGISTRY.load_steps(obj) append all obj methods to
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = re.compile("Step 1", re.I | re.U)
    expected_sentence2 = re.compile("Doing something", re.I | re.U)
    assert_in(expected_sentence1, steps)
    assert_in(expected_sentence2, steps)
    assert_equal(steps[expected_sentence1], step_list.step_1)
    assert_equal(steps[expected_sentence2], step_list.step_2)
예제 #2
0
def test_StepDict_can_exclude_methods_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load exluded attr in
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        exclude = ["step_1"]

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = re.compile("Step 1", re.I | re.U)
    expected_sentence2 = re.compile("Doing something", re.I | re.U)
    assert_not_in(expected_sentence1, steps)
    assert_in(expected_sentence2, steps)
예제 #3
0
def test_StepDict_can_exclude_methods_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load exluded attr in
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        exclude = ["step_1"]

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = re.compile("Step 1", re.I | re.U)
    expected_sentence2 = re.compile("Doing something", re.I | re.U)
    assert_not_in(expected_sentence1, steps)
    assert_in(expected_sentence2, steps)
예제 #4
0
def test_StepDict_can_load_steps_from_an_object():
    """
    aloe.STEP_REGISTRY.load_steps(obj) append all obj methods to
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = re.compile("Step 1", re.I | re.U)
    expected_sentence2 = re.compile("Doing something", re.I | re.U)
    assert_in(expected_sentence1, steps)
    assert_in(expected_sentence2, steps)
    assert_equal(steps[expected_sentence1], step_list.step_1)
    assert_equal(steps[expected_sentence2], step_list.step_2)
예제 #5
0
def test_StepDict_can_exclude_callable_object_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load callable objets in
    STEP_REGISTRY
    """
    steps = StepDict()

    class NoStep(object):
        """A class defining something that's not a step."""
        class NotAStep(object):
            """A callable which isn't a step."""
            def __call__(self):
                pass

    no_step = NoStep()
    steps.load_steps(no_step)

    assert len(steps) == 0
예제 #6
0
def test_StepDict_can_exclude_callable_object_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load callable objets in
    STEP_REGISTRY
    """
    steps = StepDict()

    class NoStep(object):
        """A class defining something that's not a step."""
        class NotAStep(object):
            """A callable which isn't a step."""
            def __call__(self):
                pass

    no_step = NoStep()
    steps.load_steps(no_step)

    assert not steps
예제 #7
0
def test_StepDict_can_load_steps_from_an_object():
    """
    aloe.STEP_REGISTRY.load_steps(obj) append all obj methods to
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    assert_matches(steps, "Step 1", (step_list.step_1, (), {}))
    assert_matches(steps, "Doing something", (step_list.step_2, (), {}))
예제 #8
0
def test_StepDict_can_load_steps_from_an_object():
    """
    aloe.STEP_REGISTRY.load_steps(obj) append all obj methods to
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    assert_matches(steps, "Step 1", (step_list.step_1, (), {}))
    assert_matches(steps, "Doing something", (step_list.step_2, (), {}))
예제 #9
0
def test_StepDict_can_exclude_methods_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load exluded attr in
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        exclude = ["step_1"]

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    assert_no_match(steps, "Step 1")
    assert_matches(steps, "Doing something", (step_list.step_2, (), {}))
예제 #10
0
def test_StepDict_can_exclude_methods_when_load_steps():
    """
    aloe.STEP_REGISTRY.load_steps(obj) don't load exluded attr in
    STEP_REGISTRY
    """
    steps = StepDict()

    class LotsOfSteps(object):
        """A class defining some steps."""
        exclude = ["step_1"]

        def step_1(self):  # pylint:disable=missing-docstring
            pass

        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    assert_no_match(steps, "Step 1")
    assert_matches(steps, "Doing something", (step_list.step_2, (), {}))