コード例 #1
0
def test_restore_not_git(runner, mock_server, docker, monkeypatch):
    with runner.isolated_filesystem():
        monkeypatch.setattr(cli, "_api", InternalApi({"project": "test"}))
        result = runner.invoke(cli.restore, ["test/abcdef"])
        print(result.output)
        print(traceback.print_tb(result.exc_info[2]))
        assert result.exit_code == 0
        assert "Original run has no git history" in result.output
コード例 #2
0
def test_restore_no_entity(runner, mock_server, git_repo, docker, monkeypatch):
    # git_repo creates it's own isolated filesystem
    mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
    monkeypatch.setattr(cli, "_api", InternalApi({"project": "test"}))
    result = runner.invoke(cli.restore, ["test/abcdef", "--no-git"])
    print(result.output)
    print(traceback.print_tb(result.exc_info[2]))
    assert result.exit_code == 0
    assert "Restored config variables" in result.output
コード例 #3
0
def test_restore_good_remote(runner, mock_server, git_repo, docker, monkeypatch):
    # git_repo creates it's own isolated filesystem
    git_repo.repo.create_remote("origin", "[email protected]:foo/bar")
    monkeypatch.setattr(subprocess, "check_call", lambda command: True)
    mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
    monkeypatch.setattr(cli, "_api", InternalApi({"project": "test"}))
    result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
    print(result.output)
    print(traceback.print_tb(result.exc_info[2]))
    assert result.exit_code == 0
    assert "Created branch wandb/abcdef" in result.output
コード例 #4
0
def test_login_anonymously(runner, monkeypatch, empty_netrc, local_netrc):
    with runner.isolated_filesystem():
        api = InternalApi()
        monkeypatch.setattr(cli, "api", api)
        monkeypatch.setattr(api, "create_anonymous_api_key",
                            lambda *args, **kwargs: DUMMY_API_KEY)
        result = runner.invoke(cli.login, ["--anonymously"])
        print("Output: ", result.output)
        print("Exception: ", result.exception)
        print("Traceback: ", traceback.print_tb(result.exc_info[2]))
        assert result.exit_code == 0
        with open("netrc", "r") as f:
            generated_netrc = f.read()
        assert DUMMY_API_KEY in generated_netrc
コード例 #5
0
ファイル: test_cli.py プロジェクト: xwzy/client
def test_restore_bad_remote(runner, mock_server, git_repo, docker, monkeypatch):
    # git_repo creates it's own isolated filesystem
    mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
    api = InternalApi({'project': 'test'})
    monkeypatch.setattr(cli, '_api', api)

    def bad_commit(cmt):
        raise ValueError()
    monkeypatch.setattr(api.git.repo, 'commit', bad_commit)
    monkeypatch.setattr(api, "download_urls", lambda *args, **kwargs: []) 
    result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
    print(result.output)
    print(traceback.print_tb(result.exc_info[2]))
    assert result.exit_code == 1
    assert "Run `git clone http://fake.git/foo/bar`" in result.output
コード例 #6
0
ファイル: test_cli.py プロジェクト: ayulockin/client
def test_restore_no_diff(runner, mock_server, git_repo, docker, monkeypatch):
    # git_repo creates it's own isolated filesystem
    git_repo.repo.create_remote("origin", "[email protected]:foo/bar")
    monkeypatch.setattr(subprocess, "check_call", lambda command: True)
    mock_server.set_context("git", {"repo": "http://fake.git/foo/bar"})
    mock_server.set_context("bucket_config",
                            {"files": ["wandb-metadata.json"]})
    monkeypatch.setattr(cli, "_api", InternalApi({"project": "test"}))
    result = runner.invoke(cli.restore, ["wandb/test:abcdef"])
    print(result.output)
    print(traceback.print_tb(result.exc_info[2]))
    assert result.exit_code == 0
    assert "Created branch wandb/abcdef" in result.output
    # no patching operaations performed, whether successful or not
    assert "Applied patch" not in result.output
    assert "Filed to apply patch" not in result.output