-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathcalls.py
More file actions
52 lines (37 loc) · 1.66 KB
/
calls.py
File metadata and controls
52 lines (37 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
This module contains REST API calls for GitHub Projects.
"""
from abc import ABC, abstractmethod
from playwright.sync_api import APIRequestContext, APIResponse, expect
from screenplay.pattern import Actor, Question
# ------------------------------------------------------------
# GitHub Project Call parent class
# ------------------------------------------------------------
class GitHubProjectCall(Question[APIResponse], ABC):
@abstractmethod
def call_as(self, actor: Actor, context: APIRequestContext) -> APIResponse:
pass
def request_as(self, actor: Actor) -> APIResponse:
context: APIRequestContext = actor.using('gh_context')
return self.call_as(actor, context)
# ------------------------------------------------------------
# GitHub Project Calls
# ------------------------------------------------------------
class create_card(GitHubProjectCall):
def __init__(self, column_id: str, note: str | None = None) -> None:
self.column_id = column_id
self.note = note
def call_as(self, actor: Actor, context: APIRequestContext) -> APIResponse:
response = context.post(
f'/projects/columns/{self.column_id}/cards',
data={'note': self.note})
expect(response).to_be_ok()
assert response.json()['note'] == self.note
return response
class retrieve_card(GitHubProjectCall):
def __init__(self, card_id: str) -> None:
self.card_id = card_id
def call_as(self, actor: Actor, context: APIRequestContext) -> APIResponse:
response = context.get(f'/projects/columns/cards/{self.card_id}')
expect(response).to_be_ok()
return response