예제 #1
0
def test_scm_client_run_cmd_no_timeout(gitrepo, tmpdir):
    """Verify timeout facility is not invoked when command completes in time"""
    client = create_scm_client(path=str(tmpdir), repo='file://' + gitrepo)
    start_time = time.time()
    client.run_cmd("sleep 1", timeout=2)
    elapsed = time.time() - start_time
    assert elapsed == pytest.approx(1, abs=0.2)
예제 #2
0
def test_scm_client_run_cmd_timeout(gitrepo, tmpdir):
    """Tests timeout facility of ScmClient"""
    client = create_scm_client(path=str(tmpdir), repo='file://' + gitrepo)
    start_time = time.time()
    with pytest.raises(AXTimeoutException):
        client.run_cmd("sleep 10", timeout=1)
    elapsed = time.time() - start_time
    assert elapsed == pytest.approx(1, abs=0.2)
예제 #3
0
def test_scm_git_get_remote_head(gitrepo, tmpdir):
    """See if we can get remote head of a branch"""
    local_dir = os.path.join(str(tmpdir), 'local')
    client = create_scm_client(repo='file://' + gitrepo, path=local_dir)
    client.init()
    client.fetch()
    actual_master_head_commit = check_output('git -C {} show-ref refs/heads/master'.format(gitrepo)).split()[0]
    master_head_commit = client.get_remote_head('master')
    assert master_head_commit == actual_master_head_commit
예제 #4
0
def test_scm_client_run_cmd_constructor_timeout(gitrepo, tmpdir):
    """Verifies cmd timeout is honored from constructor"""
    client = create_scm_client(path=str(tmpdir), repo='file://' + gitrepo, cmd_timeout=1)
    with pytest.raises(AXTimeoutException):
        client.run_cmd("sleep 2")
예제 #5
0
def test_scm_client_run_cmd_nonzero(gitrepo, tmpdir):
    """Verifies exception is raised upon non-zero return code"""
    client = create_scm_client(path=str(tmpdir), repo='file://' + gitrepo)
    with pytest.raises(AXScmException):
        client.run_cmd("exit 1", shell=True, timeout=2)