예제 #1
0
def test_project_templating(inputs, save_file):

    def mock_save_file(filename, filecontent):
        #file_to_write = os.path.join(
        #    "tests", "fixtures",
        #    "project_templating", filename)
        #path = os.path.dirname(file_to_write)
        #if not os.path.exists(path):
        #    print(path)
        #    os.mkdir(path)
        #with open(file_to_write, 'w') as f:
        #    f.write(filecontent)
        file_to_read = os.path.join(
            "tests",
            "fixtures",
            "project_templating",
            filename)
        with open(file_to_read, 'r') as f:
            expected = f.read()
            eq_(filecontent, expected)

    inputs.return_value = dict(
        project_name='test-me'
    )
    save_file.side_effect = mock_save_file
    project = Project(get_yehua_file())
    project.templating()
예제 #2
0
def test_project_copy_static(inputs, copy_file):
    copy_file.return_value = 0
    inputs.return_value = dict(project_name='test-me')
    project = Project(get_yehua_file())
    project.copy_static_files()
    calls = copy_file.call_args_list
    calls = [split_call_arguments(call) for call in calls]
    expected = [["README.rst", "test-me/.moban.d/README.rst.jj2"],
                ["test.sh", "test-me/.moban.d/test.sh.jj2"],
                ["requirements.txt", "test-me/.moban.d/requirements.txt.jj2"],
                ["setup.py.jj2", "test-me/.moban.d/setup.py.jj2"],
                [
                    "tests/requirements.txt",
                    "test-me/.moban.d/tests/requirements.txt.jj2"
                ],
                [
                    "docs/source/conf.py.jj2",
                    "test-me/.moban.d/docs/source/conf.py.jj2"
                ], ["Makefile", "test-me/Makefile"],
                ["CHANGELOG.rst", "test-me/CHANGELOG.rst"],
                ["MANIFEST.in", "test-me/MANIFEST.in"],
                ["travis.yml.jj2", "test-me/.travis.yml"],
                ["gitignore", "test-me/.gitignore"],
                ["__init__.py.jj2", "test-me/test_me/__init__.py"]]
    basepath = os.path.join(os.getcwd(), 'yehua', 'resources', 'static')
    expected = [[os.path.join(basepath, path[0]), path[1]]
                for path in expected]
    eq_(calls, expected)
예제 #3
0
def test_project_copy_static(inputs, copy_file):
    copy_file.return_value = 0
    inputs.return_value = dict(
        project_name='test-me'
    )
    project = Project(get_yehua_file())
    project.copy_static_files()
    calls = copy_file.call_args_list
    calls = [split_call_arguments(call) for call in calls]
    expected = [
        ["README.rst", "test-me/.moban.d/README.rst.jj2"],
        ["test.sh", "test-me/.moban.d/test.sh.jj2"],
        ["requirements.txt", "test-me/.moban.d/requirements.txt.jj2"],
        ["setup.py.jj2", "test-me/.moban.d/setup.py.jj2"],
        ["tests/requirements.txt", "test-me/.moban.d/tests/requirements.txt.jj2"],
        ["docs/source/conf.py.jj2", "test-me/.moban.d/docs/source/conf.py.jj2"],
        ["Makefile", "test-me/Makefile"],
        ["CHANGELOG.rst", "test-me/CHANGELOG.rst"],
        ["MANIFEST.in", "test-me/MANIFEST.in"],
        ["travis.yml.jj2", "test-me/.travis.yml"],
        ["gitignore", "test-me/.gitignore"],
        ["__init__.py.jj2", "test-me/test_me/__init__.py"]
    ]
    basepath = os.path.join(os.getcwd(), 'yehua', 'resources', 'static')
    expected = [[ os.path.join(basepath, path[0]), path[1]] for path in expected]
    eq_(calls, expected)
예제 #4
0
def test_project_get_mobans(inputs, mkdir, system_call):
    test_project_name = 'test-me'
    mkdir.return_value = 0
    inputs.return_value = dict(project_name=test_project_name)
    yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.get_mobans()
    formatter = ' && '.join([
        'cd %s',
        'git clone https://github.com/moremoban/setupmobans.git mobans',
        'cd mobans', 'git submodule init', 'git submodule update'
    ])
    system_call.assert_called_once_with(formatter % test_project_name)
예제 #5
0
def test_project(inputs, mkdir):
    mkdir.return_value = 0
    inputs.return_value = dict(project_name='test-me')
    yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.create_all_directories()
    calls = mkdir.call_args_list
    calls = [str(call) for call in calls]
    expected = [
        "call('test-me')", "call('test-me/test_me')", "call('test-me/tests')",
        "call('test-me/docs')", "call('test-me/docs/source')",
        "call('test-me/.moban.d')", "call('test-me/.moban.d/tests')",
        "call('test-me/.moban.d/docs')", "call('test-me/.moban.d/docs/source')"
    ]
    eq_(calls, expected)
예제 #6
0
파일: main.py 프로젝트: moremoban/yehua
def main():
    signal.signal(signal.SIGINT, control_c_quit)
    parser = create_parser()
    options = vars(parser.parse_args())
    handle_verbose(options["verbose"])

    yehua_file = options.get("url")
    if yehua_file is None:
        yehua_file = get_yehua_file()
    try:
        if yehua_file.endswith("git") and yehua_file.startswith("https"):
            yehua_file = yehua_file.replace("https://", "git://")

        if yehua_file.startswith("gh:"):
            yehua_file = yehua_file.replace("gh:", "git://github.com/")
            if not yehua_file.endswith(".git"):
                yehua_file = yehua_file + ".git"

        yehua = cookiecutter_json_to_yehua_file(yehua_file)
        project = CookieCutter(yehua, yehua_file)
    except FileNotFound:
        # then it is yehua file
        project = Project(yehua_file)
    project.create_all_directories()
    project.templating()
    project.copy_static_files()
    project.inflate_all_by_moban()
    project.post_moban()
    project.end()
예제 #7
0
    def test_project_templating(self):
        def mock_save_file(filename, filecontent):
            file_to_write = os.path.join("tests", "fixtures",
                                         "project_templating", filename)
            path = os.path.dirname(file_to_write)
            if not os.path.exists(path):
                print(path)
                os.mkdir(path)
            with open(file_to_write, "w") as f:
                f.write(filecontent)
            file_to_read = os.path.join("tests", "fixtures",
                                        "project_templating", filename)
            with codecs.open(file_to_read, "r", encoding="utf-8") as f:
                expected = f.read()
                self.assertMultiLineEqual(filecontent, expected)

        self.inputs.return_value = dict(project_name="test-me")
        self.save_file.side_effect = mock_save_file
        project = Project(get_yehua_file())
        project.templating()
예제 #8
0
    def test_project_templating(self):
        def mock_save_file(filename, filecontent):
            #file_to_write = os.path.join(
            #    "tests", "fixtures",
            #    "project_templating", filename)
            #path = os.path.dirname(file_to_write)
            #if not os.path.exists(path):
            #    print(path)
            #    os.mkdir(path)
            #with open(file_to_write, 'w') as f:
            #    f.write(filecontent)
            file_to_read = os.path.join("tests", "fixtures",
                                        "project_templating", filename)
            with codecs.open(file_to_read, 'r', encoding='utf-8') as f:
                expected = f.read()
                self.assertMultiLineEqual(filecontent, expected)

        self.inputs.return_value = dict(project_name='test-me')
        self.save_file.side_effect = mock_save_file
        project = Project(get_yehua_file())
        project.templating()
예제 #9
0
 def test_project_copy_static(self):
     self.copy_file.return_value = 0
     self.inputs.return_value = dict(project_name='test-me')
     project = Project(get_yehua_file())
     project.copy_static_files()
     calls = self.copy_file.call_args_list
     calls = [split_call_arguments(call) for call in calls]
     expected = [[
         "CUSTOM_README.rst", "test-me/.moban.d/CUSTOM_README.rst.jj2"
     ], ["custom_setup.py.jj2", "test-me/.moban.d/custom_setup.py.jj2"],
                 [
                     "tests/custom_requirements.txt.jj2",
                     "test-me/.moban.d/tests/custom_requirements.txt.jj2"
                 ], ["Makefile", "test-me/Makefile"],
                 ["CHANGELOG.rst", "test-me/CHANGELOG.rst"],
                 ["MANIFEST.in", "test-me/MANIFEST.in"],
                 ["setup.cfg", "test-me/setup.cfg"]]
     basepath = os.path.join(os.getcwd(), 'yehua', 'resources', 'static')
     expected = [[os.path.join(basepath, path[0]), path[1]]
                 for path in expected]
     eq_(calls, expected)
예제 #10
0
def test_project_templating(inputs, save_file):
    def mock_save_file(filename, filecontent):
        #file_to_write = os.path.join(
        #    "tests", "fixtures",
        #    "project_templating", filename)
        #path = os.path.dirname(file_to_write)
        #if not os.path.exists(path):
        #    print(path)
        #    os.mkdir(path)
        #with open(file_to_write, 'w') as f:
        #    f.write(filecontent)
        file_to_read = os.path.join("tests", "fixtures", "project_templating",
                                    filename)
        with open(file_to_read, 'r') as f:
            expected = f.read()
            eq_(filecontent, expected)

    inputs.return_value = dict(project_name='test-me')
    save_file.side_effect = mock_save_file
    project = Project(get_yehua_file())
    project.templating()
예제 #11
0
 def test_project_copy_static(self):
     self.copy_file.return_value = 0
     self.inputs.return_value = dict(project_name="test-me")
     project = Project(get_yehua_file())
     project.copy_static_files()
     calls = self.copy_file.call_args_list
     calls = [split_call_arguments(call) for call in calls]
     expected = [
         ["CUSTOM_README.rst", "test-me/.moban.d/CUSTOM_README.rst.jj2"],
         ["custom_setup.py.jj2", "test-me/.moban.d/custom_setup.py.jj2"],
         [
             "requirements.txt.jj2",
             "test-me/.moban.d/tests/custom_requirements.txt.jj2",
         ],
         ["CHANGELOG.rst", "test-me/CHANGELOG.rst"],
         ["setup.cfg", "test-me/setup.cfg"],
     ]
     updated_calls = [[os.path.basename(call[0]), call[1]]
                      for call in calls]
     for call, expectee in zip(updated_calls, expected):
         eq_(call, expectee)
예제 #12
0
def test_project(inputs, mkdir):
    mkdir.return_value = 0
    inputs.return_value = dict(
        project_name='test-me'
    )
    yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.create_all_directories()
    calls = mkdir.call_args_list
    calls = [str(call) for call in calls]
    expected = [
        "call('test-me')",
        "call('test-me/test_me')",
        "call('test-me/tests')",
        "call('test-me/docs')",
        "call('test-me/docs/source')",
        "call('test-me/.moban.d')",
        "call('test-me/.moban.d/tests')",
        "call('test-me/.moban.d/docs')",
        "call('test-me/.moban.d/docs/source')"
    ]
    eq_(calls, expected)
예제 #13
0
파일: main.py 프로젝트: jayvdb/yehua
def main():
    argument = None
    yehua_file = None
    if len(sys.argv) == 2:
        argument = sys.argv[1]
        if argument == "help":
            usage()
        else:
            yehua_file = argument
    else:
        yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.create_all_directories()
    project.templating()
    project.copy_static_files()
예제 #14
0
파일: main.py 프로젝트: jayvdb/yehua
def main():
    argument = None
    yehua_file = None
    if len(sys.argv) == 2:
        argument = sys.argv[1]
        if argument == "help":
            usage()
        else:
            yehua_file = argument
    else:
        yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.create_all_directories()
    project.templating()
    project.copy_static_files()
예제 #15
0
def test_existing_directory(inputs, mkdir):
    mkdir.return_value = 0
    inputs.return_value = dict(project_name="yehua")
    yehua_file = get_yehua_file()
    project = Project(yehua_file)
    project.create_all_directories()