def test_list_all_remotes(managed_tmpdir): from hangar.remotes import RemoteInfo runner = CliRunner() with runner.isolated_filesystem(): P = getcwd() repo = Repository(P, exists=False) res = runner.invoke(cli.init, ['--name', 'test', '--email', '*****@*****.**'], obj=repo) assert res.exit_code == 0 res = runner.invoke(cli.add_remote, ['origin', 'localhost:50051'], obj=repo) assert res.exit_code == 0 assert res.stdout == "RemoteInfo(name='origin', address='localhost:50051')\n" res = runner.invoke(cli.add_remote, ['upstream', 'foo:ip'], obj=repo) assert res.exit_code == 0 assert res.stdout == "RemoteInfo(name='upstream', address='foo:ip')\n" remote_list = repo.remote.list_all() assert remote_list == [ RemoteInfo(name='origin', address='localhost:50051'), RemoteInfo(name='upstream', address='foo:ip') ] res = runner.invoke(cli.list_remotes, obj=repo) assert res.exit_code == 0 expected_stdout = "[RemoteInfo(name='origin', address='localhost:50051'), "\ "RemoteInfo(name='upstream', address='foo:ip')]\n" assert res.stdout == expected_stdout
def test_remove_remote(): from hangar.remotes import RemoteInfo runner = CliRunner() with runner.isolated_filesystem(): P = getcwd() repo = Repository(P, exists=False) res = runner.invoke(cli.init, ['--name', 'test', '--email', '*****@*****.**'], obj=repo) assert res.exit_code == 0 res = runner.invoke(cli.add_remote, ['origin', 'localhost:50051'], obj=repo) assert res.exit_code == 0 assert res.stdout == "RemoteInfo(name='origin', address='localhost:50051')\n" remote_list = repo.remote.list_all() assert remote_list == [ RemoteInfo(name='origin', address='localhost:50051') ] res = runner.invoke(cli.remove_remote, ['origin'], obj=repo) assert res.exit_code == 0 assert res.stdout == "RemoteInfo(name='origin', address='localhost:50051')\n" assert repo.remote.list_all() == []