-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add user, refactor tests * docstring
- Loading branch information
Showing
11 changed files
with
227 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pybuildkite.client import Client | ||
|
||
|
||
class Users(Client): | ||
""" | ||
User operations for the Buildkite API | ||
""" | ||
|
||
def __init__(self, client: Client, base_url: str) -> None: | ||
""" | ||
Construct the class | ||
:param client: API Client | ||
:param base_url: Base Url | ||
""" | ||
self.client = client | ||
self.path = base_url + "user" | ||
|
||
def get_current_user(self): | ||
""" | ||
Returns the current user | ||
:return: Returns current user | ||
""" | ||
return self.client.get(self.path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from pybuildkite.agents import Agents | ||
|
||
|
||
class TestAgents: | ||
def test_get_agent(fake_client): | ||
""" | ||
Test functionality of the Agents class | ||
Test the get_agent method | ||
""" | ||
|
||
@pytest.fixture | ||
def fake_client(self): | ||
""" | ||
Build a fake API client | ||
""" | ||
return Mock(get=Mock()) | ||
|
||
def test_get_agent(self, fake_client): | ||
""" | ||
Test the get_agent method | ||
""" | ||
agents = Agents(fake_client, "base") | ||
agents.get_agent("org_slug", "agent_id") | ||
url = "base/organizations/org_slug/agents/agent_id" | ||
fake_client.get.assert_called_with(url) | ||
agents = Agents(fake_client, "base") | ||
agents.get_agent("org_slug", "agent_id") | ||
url = "base/organizations/org_slug/agents/agent_id" | ||
fake_client.get.assert_called_with(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,43 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from pybuildkite.artifacts import Artifacts | ||
|
||
|
||
class TestArtifacts: | ||
""" | ||
Test functionality of the Jobs class | ||
""" | ||
|
||
@pytest.fixture | ||
def fake_client(self): | ||
""" | ||
Build a fake API client | ||
""" | ||
return Mock(get=Mock()) | ||
|
||
def test_list_artifacts_for_build(self, fake_client): | ||
""" | ||
Test List Artifacts for build | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.list_artifacts_for_build("org_slug", "pipe_slug", "build_no") | ||
url = ( | ||
"base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/artifacts/" | ||
) | ||
fake_client.get.assert_called_with(url) | ||
|
||
def test_list_artifacts_for_job(self, fake_client): | ||
""" | ||
Test list artifacts for job | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.list_artifacts_for_job("org_slug", "pipe_slug", "build_no", 123) | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/" | ||
fake_client.get.assert_called_with(url) | ||
|
||
def test_get_artifact(self, fake_client): | ||
""" | ||
Test get Artifact | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.get_artifact("org_slug", "pipe_slug", "build_no", 123, "artifact") | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/artifact/" | ||
fake_client.get.assert_called_with(url) | ||
|
||
def test_download_artifact(self, fake_client): | ||
""" | ||
Test download Artifact | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.download_artifact( | ||
"org_slug", "pipe_slug", "build_no", 123, "artifact" | ||
) | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/artifact/download/" | ||
fake_client.get.assert_called_with(url) | ||
def test_list_artifacts_for_build(fake_client): | ||
""" | ||
Test List Artifacts for build | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.list_artifacts_for_build("org_slug", "pipe_slug", "build_no") | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/artifacts/" | ||
fake_client.get.assert_called_with(url) | ||
|
||
|
||
def test_list_artifacts_for_job(fake_client): | ||
""" | ||
Test list artifacts for job | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.list_artifacts_for_job("org_slug", "pipe_slug", "build_no", 123) | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/" | ||
fake_client.get.assert_called_with(url) | ||
|
||
|
||
def test_get_artifact(fake_client): | ||
""" | ||
Test get Artifact | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.get_artifact("org_slug", "pipe_slug", "build_no", 123, "artifact") | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/artifact/" | ||
fake_client.get.assert_called_with(url) | ||
|
||
|
||
def test_download_artifact(fake_client): | ||
""" | ||
Test download Artifact | ||
""" | ||
artifacts = Artifacts(fake_client, "base") | ||
artifacts.download_artifact("org_slug", "pipe_slug", "build_no", 123, "artifact") | ||
url = "base/organizations/org_slug/pipelines/pipe_slug/builds/build_no/jobs/123/artifacts/artifact/download/" | ||
fake_client.get.assert_called_with(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.