def test_should_catch_assertion_error():
    
    mocker = Mocker()
    
    def action_failed_method(context, *args, **kwargs):
        assert False, "bla"
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_error
    mocker.result(None)
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')

    with mocker:
        result = runner.run_stories(settings=settings, fixture=fixture, context=context)
    
        assert isinstance(action.error, AssertionError)
        assert action.error.message == "bla"
Beispiel #2
0
def test_should_execute_scenarios_successfully():

    mocker = Mocker()

    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    fixture.append_story(some_action().scenario.story)

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_successful
    mocker.result(None)

    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')
    context.language.get('when')
    mocker.result('When')
    context.language.get('then')
    mocker.result('Then')

    with mocker:
        result = runner.run_stories(settings=settings,
                                    fixture=fixture,
                                    context=context)

        assert fixture.get_status() == Status.Successful
def test_story_runner_returns_a_result_with_the_original_Fixture():
    settings = Settings()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    runner = StoryRunner()

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()
    context.settings = Mock()
    context.settings.on_before_action = None
    context.settings.on_action_successful = None
    context.settings.on_action_error = None
    context.language = Mock()
    context.language \
           .expects(once()) \
           .get(eq('given')) \
           .will(return_value('Given'))
    context.language \
           .expects(once()) \
           .get(eq('when')) \
           .will(return_value('When'))
    context.language \
           .expects(once()) \
           .get(eq('then')) \
           .will(return_value('Then'))

    result = runner.run_stories(settings, fixture, context=context)

    assert result.fixture == fixture
    context.verify()
    context.browser_driver.verify()
Beispiel #4
0
def test_should_handle_action_errors_successfully():

    mocker = Mocker()

    def action_failed_method(context, *args, **kwargs):
        raise ActionFailedError("bla")

    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_error
    mocker.result(None)
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')

    with mocker:
        result = runner.run_stories(settings=settings,
                                    fixture=fixture,
                                    context=context)

        assert fixture.get_status() == Status.Failed
def test_should_execute_scenarios_successfully():
    
    mocker = Mocker()
    
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    fixture.append_story(some_action().scenario.story)

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_successful
    mocker.result(None)
    
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')
    context.language.get('when')
    mocker.result('When')
    context.language.get('then')
    mocker.result('Then')

    with mocker:
        result = runner.run_stories(settings=settings, fixture=fixture, context=context)
    
        assert fixture.get_status() == Status.Successful
def test_should_execute_scenarios_successfully():
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    fixture.append_story(some_action().scenario.story)

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()
    context.settings = Mock()
    context.settings.on_before_action = None
    context.settings.on_action_successful = None
    context.settings.on_action_error = None
    context.language = Mock()
    context.language \
           .expects(once()) \
           .get(eq('given')) \
           .will(return_value('Given'))
    context.language \
           .expects(once()) \
           .get(eq('when')) \
           .will(return_value('When'))
    context.language \
           .expects(once()) \
           .get(eq('then')) \
           .will(return_value('Then'))

    result = runner.run_stories(settings=settings, fixture=fixture, context=context)

    assert fixture.get_status() == Status.Successful
    context.verify()
    context.browser_driver.verify()
Beispiel #7
0
def test_story_runner_returns_a_result_with_the_original_Fixture():

    mocker = Mocker()

    settings = Settings()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    runner = StoryRunner()

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_successful
    mocker.result(None)

    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')
    context.language.get('when')
    mocker.result('When')
    context.language.get('then')
    mocker.result('Then')

    with mocker:
        result = runner.run_stories(settings, fixture, context=context)

        assert result.fixture == fixture
Beispiel #8
0
def test_should_catch_assertion_error():

    mocker = Mocker()

    def action_failed_method(context, *args, **kwargs):
        assert False, "bla"

    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_error
    mocker.result(None)
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')

    with mocker:
        result = runner.run_stories(settings=settings,
                                    fixture=fixture,
                                    context=context)

        assert isinstance(action.error, AssertionError)
        assert action.error.message == "bla"
def test_should_handle_action_errors_successfully():
    
    mocker = Mocker()
    
    def action_failed_method(context, *args, **kwargs):
        raise ActionFailedError("bla")
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_error
    mocker.result(None)
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')

    with mocker:
        result = runner.run_stories(settings=settings, fixture=fixture, context=context)
    
        assert fixture.get_status() == Status.Failed
def test_story_runner_returns_a_result_with_the_original_Fixture():
    
    mocker = Mocker()
    
    settings = Settings()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    runner = StoryRunner()

    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()
    context.settings = mocker.mock()
    context.settings.on_before_action
    mocker.result(None)
    context.settings.on_action_successful
    mocker.result(None)
    
    context.language = mocker.mock()
    context.language.get('given')
    mocker.result('Given')
    context.language.get('when')
    mocker.result('When')
    context.language.get('then')
    mocker.result('Then')

    with mocker:
        result = runner.run_stories(settings, fixture, context=context)
    
        assert result.fixture == fixture
def test_story_runner_returns_a_result():
    settings = Settings()
    fixture = Fixture()
    runner = StoryRunner()
    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()

    result = runner.run_stories(settings, fixture, context=context)
    assert result is not None

    context.verify()
    context.browser_driver.verify()
def test_story_runner_returns_a_result():
    
    mocker = Mocker()
    
    settings = Settings()
    fixture = Fixture()
    runner = StoryRunner()
    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()

    with mocker:
        result = runner.run_stories(settings, fixture, context=context)
        assert result is not None
Beispiel #13
0
def test_story_runner_returns_a_result():

    mocker = Mocker()

    settings = Settings()
    fixture = Fixture()
    runner = StoryRunner()
    context = Object()
    context.browser_driver = mocker.mock()
    context.browser_driver.start_test("http://localhost")
    context.browser_driver.stop_test()

    with mocker:
        result = runner.run_stories(settings, fixture, context=context)
        assert result is not None
def test_should_execute_scenarios_successfully():
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    fixture.append_story(some_action().scenario.story)

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()

    result = runner.run_stories(settings=settings, fixture=fixture, context=context)

    assert fixture.get_status() == Status.Successful
    context.verify()
    context.browser_driver.verify()
def test_story_runner_returns_a_result_with_the_original_Fixture():
    settings = Settings()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    runner = StoryRunner()

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()

    result = runner.run_stories(settings, fixture, context=context)

    assert result.fixture == fixture
    context.verify()
    context.browser_driver.verify()
def test_should_handle_action_errors_successfully():
    def action_failed_method(context, *args, **kwargs):
        raise ActionFailedError("bla")
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()

    result = runner.run_stories(settings=settings, fixture=fixture, context=context)

    assert fixture.get_status() == Status.Failed
    context.verify()
    context.browser_driver.verify()
def test_should_record_errors_correctly():
    def action_failed_method(context, *args, **kwargs):
        raise ActionFailedError("bla")
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()
    context.settings = Mock()
    context.settings.on_before_action = None
    context.settings.on_action_successful = None
    context.settings.on_action_error = None
    context.language = Mock()
    context.language \
           .expects(once()) \
           .get(eq('given')) \
           .will(return_value('Given'))
    context.language \
           .expects(once()) \
           .get(eq('when')) \
           .will(return_value('When'))
    context.language \
           .expects(once()) \
           .get(eq('then')) \
           .will(return_value('Then'))

    result = runner.run_stories(settings=settings, fixture=fixture, context=context)

    assert isinstance(action.error, ActionFailedError)
    assert action.error.message == "bla"

    context.verify()
    context.browser_driver.verify()
def test_should_record_errors_correctly():
    def action_failed_method(context, *args, **kwargs):
        raise ActionFailedError("bla")
    settings = Settings()
    runner = StoryRunner()
    fixture = Fixture()
    action = some_action()
    fixture.append_story(action.scenario.story)
    action.execute_function = action_failed_method

    context = Mock()
    context.browser_driver = Mock()
    context.browser_driver.expects(once()).start_test(eq("http://localhost"))
    context.browser_driver.expects(once()).stop_test()

    result = runner.run_stories(settings=settings, fixture=fixture, context=context)

    assert isinstance(action.error, ActionFailedError)
    assert action.error.message == "bla"

    context.verify()
    context.browser_driver.verify()
def test_create_context_for_returns_context():
    settings = Settings()
    runner = StoryRunner()
    context = runner.create_context_for(settings)

    assert context is not None
Beispiel #20
0
def test_create_context_for_returns_context():
    settings = Settings()
    runner = StoryRunner()
    context = runner.create_context_for(settings)

    assert context is not None