Skip to content

Commit

Permalink
Merge 71a5937 into c77df2d
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Apr 26, 2021
2 parents c77df2d + 71a5937 commit a48ca64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
13 changes: 2 additions & 11 deletions conbench/api/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def get(self):
name: sha
schema:
type: string
- in: query
name: context_id
schema:
type: string
- in: query
name: machine_id
schema:
Expand All @@ -64,15 +60,10 @@ def get(self):
- Runs
"""
sha = f.request.args.get("sha")
context_id = f.request.args.get("context_id")
machine_id = f.request.args.get("machine_id")
if sha and context_id and machine_id:
if sha and machine_id:
runs = Run.search(
filters=[
Run.context_id == context_id,
Run.machine_id == machine_id,
Commit.sha == sha,
],
filters=[Run.machine_id == machine_id, Commit.sha == sha],
joins=[Commit],
)
else:
Expand Down
2 changes: 1 addition & 1 deletion conbench/entities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Run(Base, EntityMixin):
class _Serializer(EntitySerializer):
def _dump(self, run):
commit = CommitSerializer().one.dump(run.commit)
context = ContextSerializer().one.dump(run.context)
context = ContextSerializer().one.dump(run.context) if run.context else {}
machine = MachineSerializer().one.dump(run.machine)
commit.pop("links", None)
context.pop("links", None)
Expand Down
1 change: 0 additions & 1 deletion conbench/tests/api/_expected_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,6 @@
"description": "Get a list of runs.",
"parameters": [
{"in": "query", "name": "sha", "schema": {"type": "string"}},
{"in": "query", "name": "context_id", "schema": {"type": "string"}},
{"in": "query", "name": "machine_id", "schema": {"type": "string"}},
],
"responses": {
Expand Down
18 changes: 5 additions & 13 deletions conbench/tests/api/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,20 @@ def test_run_list(self, client):
response = client.get("/api/runs/")
self.assert_200_ok(response, contains=_expected_entity(run))

def test_run_list_filter_by_run_keys(self, client):
def test_run_list_filter_by_sha_and_machine(self, client):
sha = "02addad336ba19a654f9c857ede546331be7b631"
self.authenticate(client)
run = self._create()
args = {
"sha": sha,
"machine_id": run.machine_id,
"context_id": run.context_id,
}
args = {"sha": sha, "machine_id": run.machine_id}
args = urllib.parse.urlencode(args)
response = client.get(f"/api/runs/?{args}")
self.assert_200_ok(response, contains=_expected_entity(run))

def test_run_list_filter_by_run_keys_no_match(self, client):
def test_run_list_filter_by_sha_and_machine_no_match(self, client):
sha = "02addad336ba19a654f9c857ede546331be7b631"
self.authenticate(client)
run = self._create()
args = {
"sha": sha,
"machine_id": "some other machine id",
"context_id": run.context_id,
}
self._create()
args = {"sha": sha, "machine_id": "some other machine id"}
args = urllib.parse.urlencode(args)
response = client.get(f"/api/runs/?{args}")
self.assert_200_ok(response, [])

0 comments on commit a48ca64

Please sign in to comment.