当前位置: 首页>>代码示例>>Python>>正文


Python FileParser.get_stories方法代码示例

本文整理汇总了Python中pyccuracy.parsers.FileParser.get_stories方法的典型用法代码示例。如果您正苦于以下问题:Python FileParser.get_stories方法的具体用法?Python FileParser.get_stories怎么用?Python FileParser.get_stories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyccuracy.parsers.FileParser的用法示例。


在下文中一共展示了FileParser.get_stories方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_parsing_folder_with_no_stories_returns_empty_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_folder_with_no_stories_returns_empty_list():
    settings = Settings()
    settings.tests_dirs = [abspath(join(dirname(__file__), "no_stories_folder"))]
    parser = FileParser()

    fixture = parser.get_stories(settings=settings)
    assert len(fixture.stories) == 0
开发者ID:Desperado,项目名称:pyccuracy,代码行数:9,代码来源:test_file_parser.py

示例2: test_parsing_files_with_empty_content_returns_invalid_files_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_empty_content_returns_invalid_files_list():
    
    mocker = Mocker()
    
    settings = Settings()
    files = ["some path"]

    story_text = ""

    filemock = mocker.mock()
    filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
    mocker.result(files)
    filemock.read_file(files[0])
    mocker.result(story_text)

    language_mock = mocker.mock()
    language_mock.get("as_a")
    mocker.result("As a")
    language_mock.get("i_want_to")
    mocker.result("I want to")
    language_mock.get("so_that")
    mocker.result("So that")
    language_mock.get("no_header_failure")
    mocker.result("No header found")

    with mocker:
        parser = FileParser(language=language_mock, file_object=filemock)
    
        fixture = parser.get_stories(settings=settings)
        assert len(fixture.no_story_header) == 1
        file_path = fixture.no_story_header[0]
        assert file_path == "some path"
开发者ID:Desperado,项目名称:pyccuracy,代码行数:34,代码来源:test_file_parser.py

示例3: test_parsing_files_with_many_scenarios_returns_parsed_scenarios

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_many_scenarios_returns_parsed_scenarios():
    class DoSomethingAction(ActionBase):
        regex = r'I do something$'
        def execute(context, *args, **kwargs):
            pass

    class DoSomethingElseAction(ActionBase):
        regex = r'I do something else$'
        def execute(context, *args, **kwargs):
            pass

    class DoYetAnotherThingAction(ActionBase):
        regex = r'I do yet another thing$'
        def execute(context, *args, **kwargs):
            pass

    settings = Settings()
    settings.tests_dirs = [abspath(dirname(__file__))]
    settings.file_pattern = "some_test.acc"

    parser = FileParser()

    fixture = parser.get_stories(settings=settings)

    assert_no_invalid_stories(fixture)

    assert len(fixture.stories) == 1, "Expected 1, Actual: %d" % len(fixture.stories)
    assert len(fixture.stories[0].scenarios) == 2
    assert "#some custom comment" in fixture.stories[0].scenarios[1].whens[0].description
开发者ID:Desperado,项目名称:pyccuracy,代码行数:31,代码来源:test_file_parser.py

示例4: test_parsing_files_with_proper_header_returns_parsed_scenario

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_proper_header_returns_parsed_scenario():
    
    mocker = Mocker()
    
    settings = Settings()
    files = ["some path"]
    
    story_text = """As a someone
I want to do something
So that I'm happy"""

    filemock = mocker.mock()
    filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
    mocker.result(files)
    filemock.read_file(files[0])
    mocker.result(story_text)

    language_mock = mocker.mock()
    language_mock.get("as_a")
    mocker.result("As a")
    language_mock.get("i_want_to")
    mocker.result("I want to")
    language_mock.get("so_that")
    mocker.result("So that")

    with mocker:
        parser = FileParser(language=language_mock, file_object=filemock)
    
        fixture = parser.get_stories(settings=settings)
        assert len(fixture.stories) == 1
        assert fixture.stories[0].as_a == "someone"
        assert fixture.stories[0].i_want_to == "do something"
        assert fixture.stories[0].so_that == "I'm happy"
开发者ID:Desperado,项目名称:pyccuracy,代码行数:35,代码来源:test_file_parser.py

示例5: test_parsing_stories_returns_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_stories_returns_list():
    settings = Settings()
    filemock = Mock()
    filemock.expects(once()) \
            .list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
            .will(return_value([]))
    parser = FileParser(file_object=filemock)

    fixture = parser.get_stories(settings=settings)
    assert isinstance(fixture, Fixture)
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:12,代码来源:test_file_parser.py

示例6: test_parsing_files_with_wrong_so_that_returns_no_story_header_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_wrong_so_that_returns_no_story_header_list():
    settings = Settings()
    settings.tests_dirs = [abspath(join(dirname(__file__), "invalid_content_stories"))]
    settings.file_pattern = "invalid_so_that.acc"

    parser = FileParser()

    fixture = parser.get_stories(settings=settings)

    assert len(fixture.no_story_header) == 1
    file_path = fixture.no_story_header[0]
    assert file_path.endswith("invalid_so_that.acc")
开发者ID:Desperado,项目名称:pyccuracy,代码行数:14,代码来源:test_file_parser.py

示例7: test_parsing_folder_with_no_stories_returns_empty_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_folder_with_no_stories_returns_empty_list():
    settings = Settings()
    files = []
    filemock = Mock()
    filemock.expects(once()) \
            .list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
            .will(return_value(files))

    parser = FileParser(file_object=filemock)

    fixture = parser.get_stories(settings=settings)
    assert len(fixture.stories) == 0
    filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:15,代码来源:test_file_parser.py

示例8: test_parsing_stories_returns_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_stories_returns_list():
    
    mocker = Mocker()
    
    settings = Settings()
    filemock = mocker.mock()
    filemock.list_files(directories=settings.tests_dirs, pattern=settings.file_pattern)
    mocker.result([])
    
    with mocker:
        parser = FileParser(file_object=filemock)
    
        fixture = parser.get_stories(settings=settings)
        assert isinstance(fixture, Fixture)
开发者ID:Desperado,项目名称:pyccuracy,代码行数:16,代码来源:test_file_parser.py

示例9: test_parsing_files_with_invalid_so_that_returns_invalid_files_list

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_invalid_so_that_returns_invalid_files_list():
    settings = Settings()
    files = ["some path"]
    
    story_text = """As a someone
I want to do something
So I'm happy"""

    filemock = Mock()
    filemock.expects(once()) \
            .list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
            .will(return_value(files))
    filemock.expects(once()) \
            .read_file(eq(files[0])) \
            .will(return_value(story_text))

    language_mock = Mock()
    language_mock.expects(once()) \
                 .get(eq("as_a")) \
                 .will(return_value("As a"))
    language_mock.expects(once()) \
                 .get(eq("i_want_to")) \
                 .will(return_value("I want to"))
    language_mock.expects(once()) \
                 .get(eq("so_that")) \
                 .will(return_value("So that"))
    language_mock.expects(once()) \
                 .get(eq("no_header_failure")) \
                 .will(return_value("No header found"))

    parser = FileParser(language=language_mock, file_object=filemock)

    fixture = parser.get_stories(settings=settings)
    assert len(fixture.no_story_header) == 1
    file_path = fixture.no_story_header[0]
    assert file_path == "some path"
    language_mock.verify()
    filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:40,代码来源:test_file_parser.py

示例10: test_parsing_files_with_proper_header_returns_parsed_scenario

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_proper_header_returns_parsed_scenario():
    settings = Settings()
    files = ["some path"]
    
    story_text = """As a someone
I want to do something
So that I'm happy"""

    filemock = Mock()
    filemock.expects(once()) \
            .list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
            .will(return_value(files))
    filemock.expects(once()) \
            .read_file(eq(files[0])) \
            .will(return_value(story_text))

    language_mock = Mock()
    language_mock.expects(once()) \
                 .get(eq("as_a")) \
                 .will(return_value("As a"))
    language_mock.expects(once()) \
                 .get(eq("i_want_to")) \
                 .will(return_value("I want to"))
    language_mock.expects(once()) \
                 .get(eq("so_that")) \
                 .will(return_value("So that"))

    parser = FileParser(language=language_mock, file_object=filemock)

    fixture = parser.get_stories(settings=settings)
    assert len(fixture.stories) == 1
    assert fixture.stories[0].as_a == "someone"
    assert fixture.stories[0].i_want_to == "do something"
    assert fixture.stories[0].so_that == "I'm happy"
    language_mock.verify()
    filemock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:38,代码来源:test_file_parser.py

示例11: test_parsing_files_with_many_scenarios_returns_parsed_scenarios

# 需要导入模块: from pyccuracy.parsers import FileParser [as 别名]
# 或者: from pyccuracy.parsers.FileParser import get_stories [as 别名]
def test_parsing_files_with_many_scenarios_returns_parsed_scenarios():
    class DoSomethingAction:
        def execute(context, *args, **kwargs):
            pass

    class DoSomethingElseAction:
        def execute(context, *args, **kwargs):
            pass
    class DoYetAnotherThingAction:
        def execute(context, *args, **kwargs):
            pass

    settings = Settings()
    files = ["some path"]
    
    story_text = """As a someone
I want to do something
So that I'm happy

Scenario 1 - Test Scenario
Given
    I do something
When
    I do something else
Then
    I do yet another thing

Scenario 2 - Test Scenario
Given
    I do something
When
    #some custom comment
Then
    I do yet another thing"""

    filemock = Mock()
    filemock.expects(once()) \
            .list_files(directories=same(settings.tests_dirs), pattern=same(settings.file_pattern)) \
            .will(return_value(files))
    filemock.expects(once()) \
            .read_file(eq(files[0])) \
            .will(return_value(story_text))

    language_mock = Mock()
    language_mock.expects(at_least_once()) \
                 .get(eq("as_a")) \
                 .will(return_value("As a"))
    language_mock.expects(at_least_once()) \
                 .get(eq("i_want_to")) \
                 .will(return_value("I want to"))
    language_mock.expects(at_least_once()) \
                 .get(eq("so_that")) \
                 .will(return_value("So that"))
    language_mock.expects(at_least_once()) \
                 .get(eq("given")) \
                 .will(return_value("Given"))
    language_mock.expects(at_least_once()) \
                 .get(eq("when")) \
                 .will(return_value("When"))
    language_mock.expects(at_least_once()) \
                 .get(eq("then")) \
                 .will(return_value("Then"))
    language_mock.expects(at_least_once()) \
                 .get(eq("scenario")) \
                 .will(return_value("Scenario"))

    action_registry_mock = Mock()
    action_registry_mock.expects(at_least_once()) \
                        .suitable_for(eq("I do something"), eq('en-us')) \
                        .will(return_value((DoSomethingAction, [], {})))
    action_registry_mock.expects(at_least_once()) \
                        .suitable_for(eq("I do something else"), eq('en-us')) \
                        .will(return_value((DoSomethingElseAction, [], {})))
    action_registry_mock.expects(at_least_once()) \
                        .suitable_for(eq("I do yet another thing"), eq('en-us')) \
                        .will(return_value((DoYetAnotherThingAction, [], {})))

    parser = FileParser(language=language_mock, file_object=filemock, action_registry=action_registry_mock)

    fixture = parser.get_stories(settings=settings)

    assert_no_invalid_stories(fixture)

    assert len(fixture.stories) == 1, "Expected 1, Actual: %d" % len(fixture.stories)
    assert len(fixture.stories[0].scenarios) == 2
    assert fixture.stories[0].scenarios[1].whens[0].description == "#some custom comment"

    language_mock.verify()
    filemock.verify()
    action_registry_mock.verify()
开发者ID:andrewsmedina,项目名称:pyccuracy,代码行数:92,代码来源:test_file_parser.py


注:本文中的pyccuracy.parsers.FileParser.get_stories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。