def test_append_then_adds_right_class_to_thens_in_scenario():
    story = Story(as_a="Someone", i_want_to="do something", so_that="something", identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    args = ["a"]
    kwargs = {"extra_args":"something"}
    scenario.add_then("some action", lambda: None, args, kwargs)
    assert isinstance(scenario.thens[0], Action), "There should be one then of type Action in the scenario but there was %s" % scenario.thens[0].__class__
Esempio n. 2
0
def test_story_ellapsed_returns_zero_for_non_finished_stories():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.start_run()
    expected = 0
    ellapsed = int(scenario.ellapsed())
    assert ellapsed == expected, "The ellapsed time should be %d but was %d" % (
        expected, ellapsed)
def test_append_then_adds_to_thens_in_scenario():
    story = Story(as_a="Someone", i_want_to="do something", so_that="something", identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    args = ["a"]
    kwargs = {"extra_args":"something"}
    scenario.add_then("some action", lambda: None, args, kwargs)
    assert len(scenario.thens) == 1, "There should be one then in the scenario but there was %d" % len(scenario.thens)
Esempio n. 4
0
def test_marking_scenario_as_successful_also_marks_story_as_failed_if_story_exists(
):
    story = Story(as_a="Someone",
                  i_want_to="do something",
                  so_that="something",
                  identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    scenario.mark_as_successful()
    assert story.status == Status.Successful, "The status should be %s but was %s" % (
        Status.Successful, story.status)
Esempio n. 5
0
def test_append_then_adds_to_thens_in_scenario():
    story = Story(as_a="Someone",
                  i_want_to="do something",
                  so_that="something",
                  identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    args = ["a"]
    kwargs = {"extra_args": "something"}
    scenario.add_then("some action", lambda: None, args, kwargs)
    assert len(
        scenario.thens
    ) == 1, "There should be one then in the scenario but there was %d" % len(
        scenario.thens)
Esempio n. 6
0
def test_append_then_adds_right_class_to_thens_in_scenario():
    story = Story(as_a="Someone",
                  i_want_to="do something",
                  so_that="something",
                  identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    args = ["a"]
    kwargs = {"extra_args": "something"}
    scenario.add_then("some action", lambda: None, args, kwargs)
    assert isinstance(
        scenario.thens[0], Action
    ), "There should be one then of type Action in the scenario but there was %s" % scenario.thens[
        0].__class__
Esempio n. 7
0
def test_story_returns_right_repr():
    scenario = Scenario(index="1", title="Do Something", story=None)
    expected = u"Scenario 1 - Do Something (0 givens, 0 whens, 0 thens) - UNKNOWN"
    assert unicode(scenario) == expected, "Unicode Expected: %s Actual: %s" % (
        expected, unicode(scenario))
    assert str(scenario) == expected, "Str Expected: %s Actual: %s" % (
        expected, str(scenario))
Esempio n. 8
0
def test_creating_a_scenario_keeps_the_story():
    story = Story(as_a="Someone",
                  i_want_to="do something",
                  so_that="something",
                  identity="Some File")
    scenario = Scenario(index=None, title=None, story=story)
    assert str(story) == str(
        scenario.story), "story should be %s but was %s" % (
            str(story), str(scenario.story))
Esempio n. 9
0
def some_action():
    story = Story(as_a="Someone",
                  i_want_to="Do Something",
                  so_that="I'm Happy",
                  identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    return Action(scenario=scenario,
                  description="Some Action",
                  execute_function=lambda: None,
                  args=["s"],
                  kwargs={"a": "b"})
Esempio n. 10
0
def test_scenario_ellapsed_returns_seconds():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.start_run()
    time.sleep(0.1)
    scenario.end_run()

    expected = "0.1"
    ellapsed = "%.1f" % scenario.ellapsed()
    assert ellapsed == expected, "The ellapsed time should be %s but was %s" % (
        expected, ellapsed)
def test_scenario_ellapsed_returns_seconds():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.start_run()
    time.sleep(0.1)
    scenario.end_run()

    expected = "0.1"
    ellapsed = "%.1f" % scenario.ellapsed()
    assert ellapsed == expected, "The ellapsed time should be %s but was %s" % (expected, ellapsed)
Esempio n. 12
0
def test_mark_scenario_as_successful():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_successful()
    assert scenario.status == Status.Successful, "The status should be %s but was %s" % (
        Status.Successful, scenario.status)
Esempio n. 13
0
def test_mark_scenario_as_failed():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_failed()
    assert scenario.status == Status.Failed, "The status should be %s but was %s" % (
        Status.Failed, scenario.status)
def test_mark_scenario_as_failed():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_failed()
    assert scenario.status == Status.Failed, "The status should be %s but was %s" % (Status.Failed, scenario.status)
Esempio n. 15
0
def test_creating_a_scenario_starts_with_unknown_status():
    scenario = Scenario(index="1", title="Something", story=None)
    assert scenario.status == Status.Unknown, "Scenario should start with Unknown status but was %s" % scenario.status
Esempio n. 16
0
def test_creating_a_scenario_starts_with_empty_thens():
    scenario = Scenario(index="1", title="Something", story=None)
    assert scenario.thens == [], "Scenario should start with no thens but was %s" % scenario.thens
Esempio n. 17
0
def test_creating_a_scenario_starts_with_empty_times():
    scenario = Scenario(index="1", title="Something", story=None)
    assert scenario.start_time == None, "Scenario should start with no start time but was %s" % scenario.start_time
    assert scenario.end_time == None, "Scenario should start with no end time but was %s" % scenario.end_time
def test_mark_scenario_as_successful():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_successful()
    assert scenario.status == Status.Successful, "The status should be %s but was %s" % (Status.Successful, scenario.status)
Esempio n. 19
0
def test_creating_a_scenario_keeps_title():
    expected = "some title"
    scenario = Scenario(index=None, title=expected, story=None)
    assert scenario.title == expected, "title should be %s but was %s" % (
        expected, scenario.title)
Esempio n. 20
0
def test_creating_a_scenario_keeps_index():
    expected = "1"
    scenario = Scenario(index=expected, title=None, story=None)
    assert scenario.index == expected, "Index should be %s but was %s" % (
        expected, scenario.index)
def test_mark_scenario_as_successful_after_failed_has_no_effect():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_failed()
    scenario.mark_as_successful()
    assert scenario.status == Status.Failed, "The status should be %s but was %s" % (Status.Failed, scenario.status)
def test_marking_scenario_as_successful_also_marks_story_as_failed_if_story_exists():
    story = Story(as_a="Someone", i_want_to="do something", so_that="something", identity="Some File")
    scenario = Scenario(index="1", title="Something", story=story)
    scenario.mark_as_successful()
    assert story.status == Status.Successful, "The status should be %s but was %s" % (Status.Successful, story.status)
Esempio n. 23
0
def test_mark_scenario_as_successful_after_failed_has_no_effect():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.mark_as_failed()
    scenario.mark_as_successful()
    assert scenario.status == Status.Failed, "The status should be %s but was %s" % (
        Status.Failed, scenario.status)
def test_scenario_end_run_marks_time():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.end_run()
    assert scenario.end_time is not None, "There should be some end time after end_run"
Esempio n. 25
0
def test_scenario_end_run_marks_time():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.end_run()
    assert scenario.end_time is not None, "There should be some end time after end_run"
Esempio n. 26
0
def test_creating_a_scenario_returns_a_scenario():
    scenario = Scenario(index=None, title=None, story=None)
    assert isinstance(scenario, Scenario)
def test_story_ellapsed_returns_zero_for_non_finished_stories():
    scenario = Scenario(index="1", title="Something", story=None)
    scenario.start_run()
    expected = 0
    ellapsed = int(scenario.ellapsed())
    assert ellapsed == expected, "The ellapsed time should be %d but was %d" % (expected, ellapsed)