Beispiel #1
0
def repo(monkeypatch, managed_tmpdir):
    cwd = Path(managed_tmpdir)
    monkeypatch.setattr(Path, 'cwd', lambda: cwd)
    cwd.joinpath(".git").mkdir()
    cwd.joinpath(".gitignore").touch()
    init_repo('s', '[email protected]', overwrite=True)
    yield None
 def test_stock_init_on_existing_hangar_repo(self, cwd):
     repo = hangar.Repository(cwd, exists=False)
     repo.init("a", "[email protected]")
     repo._env._close_environments()
     assert not cwd.joinpath("head.stock").exists()
     init_repo()
     assert cwd.joinpath("head.stock").exists()
     with open(cwd.joinpath(".gitignore")) as f:
         assert "\n.hangar\n" in f.read()
Beispiel #3
0
 def test_stock_init_on_existing_hangar_repo(self, cwd):
     repo = hangar.Repository(cwd, exists=False)
     repo.init('a', '[email protected]')
     repo._env._close_environments()
     assert not cwd.joinpath('head.stock').exists()
     init_repo()
     assert cwd.joinpath('head.stock').exists()
     with open(cwd.joinpath('.gitignore')) as f:
         assert '\n.hangar\n' in f.read()
Beispiel #4
0
def test_get_stock_obj(managed_tmpdir, monkeypatch):
    cwd = Path(managed_tmpdir)
    monkeypatch.setattr(Path, "cwd", lambda: cwd)
    with pytest.raises(RuntimeError):
        cli.get_stock_obj(cwd)
    cwd.joinpath(".git").mkdir()
    cwd.joinpath(".gitignore").touch()
    init_repo("test", "*****@*****.**")
    stock_obj = cli.get_stock_obj(cwd)
    assert stock_obj.path == cwd
 def test_init(self, repo_path):
     cwd = repo_path
     cwd.joinpath(".git").mkdir()
     with pytest.raises(ValueError):
         init_repo(overwrite=True)
     with pytest.raises(ValueError):
         init_repo(name="some", overwrite=True)
     with pytest.raises(ValueError):
         init_repo(email="some", overwrite=True)
     init_repo("s", "[email protected]", overwrite=True)
     with open(cwd.joinpath(".gitignore")) as f:
         assert "\n.hangar\n" in f.read()
     assert cwd.joinpath(".hangar").exists()
     assert cwd.joinpath("head.stock").exists()
Beispiel #6
0
 def test_init(self, repo_path):
     cwd = repo_path
     cwd.joinpath(".git").mkdir()
     with pytest.raises(ValueError):
         init_repo(overwrite=True)
     with pytest.raises(ValueError):
         init_repo(name='some', overwrite=True)
     with pytest.raises(ValueError):
         init_repo(email='some', overwrite=True)
     init_repo('s', '[email protected]', overwrite=True)
     with open(cwd.joinpath('.gitignore')) as f:
         assert '\n.hangar\n' in f.read()
     assert cwd.joinpath('.hangar').exists()
     assert cwd.joinpath('head.stock').exists()
Beispiel #7
0
 def test_init_on_non_git_folder(self, repo_path):
     with pytest.raises(RuntimeError):
         init_repo('s', '[email protected]', overwrite=True)