Example #1
0
    def it_creates_a_new_config_file(tmpdir):
        tmpdir.chdir()

        expect(gitman.init()) == True

        expect(Config().__mapper__.text) == strip("""
        location: gitman_sources
        sources:
        - name: sample_dependency
          type: git
          repo: https://github.com/githubtraining/hellogitworld
          sparse_paths:
          -
          rev: master
          link:
          scripts:
          -
        sources_locked:
        - name: sample_dependency
          type: git
          repo: https://github.com/githubtraining/hellogitworld
          sparse_paths:
          -
          rev: ebbbf773431ba07510251bb03f9525c7bab2b13a
          link:
          scripts:
          -
        groups: []
        """)
Example #2
0
    def test_init_defaults(self):
        """Verify a config has a default filename and location."""
        config = Config('mock/root')

        assert 'mock/root' == config.root
        assert 'gitman.yml' == config.filename
        assert 'gitman_sources' == config.location
        assert [] == config.sources
Example #3
0
def config():
    log.info("Temporary directory: %s", TMP)

    with suppress(FileNotFoundError, PermissionError):
        shutil.rmtree(TMP)
    with suppress(FileExistsError):
        os.makedirs(TMP)
    os.chdir(TMP)

    os.system("touch .git")
    config = Config(root=TMP)
    config.__mapper__.text = CONFIG

    log.debug("File listing: %s", os.listdir(TMP))

    yield config

    os.chdir(ROOT)
Example #4
0
    def test_install_and_list(self):
        """Verify the correct dependencies are installed."""
        config = Config(FILES)

        count = config.install_dependencies()
        assert 7 == count

        deps = list(config.get_dependencies())
        assert 7 == len(deps)
        assert '1de84ca1d315f81b035cd7b0ecf87ca2025cdacd' == deps[0][2]
        assert '050290bca3f14e13fd616604202b579853e7bfb0' == deps[1][2]
        assert 'fb693447579235391a45ca170959b5583c5042d8' == deps[2][2]
        # master branch always changes --------------------- deps[3][2]
        # master branch always changes --------------------- deps[4][2]
        assert '7bd138fe7359561a8c2ff9d195dff238794ccc04' == deps[5][2]
        assert '2da24fca34af3748e3cab61db81a2ae8b35aec94' == deps[6][2]

        assert 5 == len(list(config.get_dependencies(depth=2)))

        assert 3 == len(list(config.get_dependencies(depth=1)))

        assert 0 == len(list(config.get_dependencies(depth=0)))
Example #5
0
    def test_install_and_list(self):
        """Verify the correct dependencies are installed."""
        config = Config(FILES)

        count = config.install_deps()
        assert 7 == count

        deps = list(config.get_deps())
        assert 7 == len(deps)
        assert 'eb37743011a398b208dd9f9ef79a408c0fc10d48' == deps[0][2]
        assert 'ddbe17ef173538d1fda29bd99a14bab3c5d86e78' == deps[1][2]
        assert 'fb693447579235391a45ca170959b5583c5042d8' == deps[2][2]
        # master branch always changes --------------------- deps[3][2]
        # master branch always changes --------------------- deps[4][2]
        assert '7bd138fe7359561a8c2ff9d195dff238794ccc04' == deps[5][2]
        assert '2da24fca34af3748e3cab61db81a2ae8b35aec94' == deps[6][2]

        assert 5 == len(list(config.get_deps(depth=2)))

        assert 3 == len(list(config.get_deps(depth=1)))

        assert 0 == len(list(config.get_deps(depth=0)))
Example #6
0
    def test_install_with_depth_0(self):
        """Verify an install depth of 0 installs nothing."""
        config = Config(FILES)

        count = config.install_dependencies(depth=0)
        assert 0 == count
Example #7
0
    def test_install_with_dirs_unknown(self):
        """Verify zero dependencies are installed with unknown dependency."""
        config = Config(FILES)

        count = config.install_dependencies('foobar')
        assert 0 == count
Example #8
0
    def test_install_with_dirs(self):
        """Verify the dependency list can be filtered."""
        config = Config(FILES)

        count = config.install_dependencies('gitman_2', 'gitman_3')
        assert 2 == count
Example #9
0
    def test_path(self):
        """Verify the path is correct."""
        config = Config('mock/root')

        assert os.path.normpath("mock/root/gitman.yml") == config.path
Example #10
0
    def test_init_location(self):
        """Verify the location can be customized."""
        config = Config('mock/root', location='.gitman')

        assert 'gitman.yml' == config.filename
        assert '.gitman' == config.location
Example #11
0
    def test_install_with_dirs_unknown(self):
        """Verify zero dependencies are installed with an unknown dependency."""
        config = Config(FILES)

        count = config.install_deps('foobar')
        assert 0 == count
Example #12
0
 def config():
     return Config('m/root', 'm.ext', 'm/location')
Example #13
0
    def test_install_with_depth_2(self):
        """Verify an install depth of 2 installs 1 level of nesting."""
        config = Config(FILES)

        count = config.install_deps(depth=2)
        assert 5 == count
Example #14
0
    def test_install_with_depth_1(self):
        """Verify an install depth of 1 installs the direct dependencies."""
        config = Config(FILES)

        count = config.install_deps(depth=1)
        assert 3 == count
Example #15
0
    def test_install_with_depth_0(self):
        """Verify an install depth of 0 installs nothing."""
        config = Config(FILES)

        count = config.install_deps(depth=0)
        assert 0 == count
Example #16
0
    def test_install_with_depth_1(self):
        """Verify an install depth of 1 installs the direct dependencies."""
        config = Config(FILES)

        count = config.install_dependencies(depth=1)
        assert 3 == count
Example #17
0
    def test_init_filename(self):
        """Verify the filename can be customized."""
        config = Config('mock/root', 'mock.custom')

        assert 'mock.custom' == config.filename
        assert 'gitman_sources' == config.location
Example #18
0
    def test_install_with_depth_2(self):
        """Verify an install depth of 2 installs 1 level of nesting."""
        config = Config(FILES)

        count = config.install_dependencies(depth=2)
        assert 5 == count
Example #19
0
    def test_install_with_dirs(self):
        """Verify the dependency list can be filtered."""
        config = Config(FILES)

        count = config.install_deps('gitman_2', 'gitman_3')
        assert 2 == count