99import os
1010import pytest
1111
12- 13- # ------------------------------------------------------------
14- # DuckDuckGo search fixtures
15- # ------------------------------------------------------------
16- 1712from pages .result import DuckDuckGoResultPage
1813from pages .search import DuckDuckGoSearchPage
19- from playwright .sync_api import Page
14+ from playwright .sync_api import Playwright , APIRequestContext , Page , expect
15+ from typing import Generator
2016
2117
18+ # ------------------------------------------------------------
19+ # DuckDuckGo search fixtures
20+ # ------------------------------------------------------------
2221
2322@pytest .fixture
2423def result_page (page : Page ) -> DuckDuckGoResultPage :
@@ -36,36 +35,39 @@ def search_page(page: Page) -> DuckDuckGoSearchPage:
3635
3736# Environment variables
3837
39- def _get_env_var (varname ) :
38+ def _get_env_var (varname : str ) -> str :
4039 value = os .getenv (varname )
4140 assert value , f'{ varname } is not set'
4241 return value
4342
4443
4544@pytest .fixture (scope = 'session' )
46- def gh_username ():
45+ def gh_username ()-> str :
4746 return _get_env_var ('GITHUB_USERNAME' )
4847
4948
5049@pytest .fixture (scope = 'session' )
51- def gh_password ():
50+ def gh_password ()-> str :
5251 return _get_env_var ('GITHUB_PASSWORD' )
5352
5453
5554@pytest .fixture (scope = 'session' )
56- def gh_access_token ():
55+ def gh_access_token ()-> str :
5756 return _get_env_var ('GITHUB_ACCESS_TOKEN' )
5857
5958
6059@pytest .fixture (scope = 'session' )
61- def gh_project_name ():
60+ def gh_project_name ()-> str :
6261 return _get_env_var ('GITHUB_PROJECT_NAME' )
6362
6463
6564# Request context
6665
6766@pytest .fixture (scope = 'session' )
68- def gh_context (playwright , gh_access_token ):
67+ def gh_context (
68+ playwright : Playwright ,
69+ gh_access_token : str ) -> Generator [APIRequestContext , None , None ]:
70+ 6971 headers = {
7072 "Accept" : "application/vnd.github.v3+json" ,
7173 "Authorization" : f"token { gh_access_token } " }
@@ -81,10 +83,14 @@ def gh_context(playwright, gh_access_token):
8183# GitHub project requests
8284
8385@pytest .fixture (scope = 'session' )
84- def gh_project (gh_context , gh_username , gh_project_name ):
86+ def gh_project (
87+ gh_context : APIRequestContext ,
88+ gh_username : str ,
89+ gh_project_name : str ) -> dict :
90+ 8591 resource = f'/users/{ gh_username } /projects'
8692 response = gh_context .get (resource )
87- assert response . ok
93+ expect ( response ). to_be_ok ()
8894
8995 name_match = lambda x : x ['name' ] == gh_project_name
9096 filtered = filter (name_match , response .json ())
@@ -95,15 +101,18 @@ def gh_project(gh_context, gh_username, gh_project_name):
95101
96102
97103@pytest .fixture ()
98- def project_columns (gh_context , gh_project ):
104+ def project_columns (
105+ gh_context : APIRequestContext ,
106+ gh_project : dict ) -> list [dict ]:
107+ 99108 response = gh_context .get (gh_project ['columns_url' ])
100- assert response . ok
109+ expect ( response ). to_be_ok ()
101110
102111 columns = response .json ()
103112 assert len (columns ) >= 2
104113 return columns
105114
106115
107116@pytest .fixture ()
108- def project_column_ids (project_columns ) :
117+ def project_column_ids (project_columns : list [ dict ]) -> list [ str ] :
109118 return list (map (lambda x : x ['id' ], project_columns ))
0 commit comments