11from __future__ import annotations
22
3+ import dataclasses
34import typing as t
45
56import pytest
@@ -16,7 +17,35 @@ def _env(monkeypatch: pytest.MonkeyPatch) -> None:
1617 monkeypatch .setenv ("INPUT_GITHUB_TOKEN" , "my_gh_token" )
1718
1819
19- def test_thanker (httpserver : HTTPServer ) -> None :
20+ @dataclasses .dataclass
21+ class DummyAuthor :
22+ id : int
23+ login : str
24+ path : str
25+ type : str
26+
27+
28+ @pytest .mark .parametrize (
29+ "author,expected" ,
30+ [
31+ pytest .param (
32+ DummyAuthor (101 , "jappleseed" , "users/j.appleseed" , "User" ),
33+ " -- _**Thanks @jappleseed!**_" ,
34+ id = "third_party_contributor" ,
35+ ),
36+ pytest .param (
37+ DummyAuthor (1 , "user1" , "users/user1" , "User" ),
38+ "" ,
39+ id = "org_member" ,
40+ ),
41+ pytest .param (
42+ DummyAuthor (2 , "dependabot[bot]" , "users/dependabot[bot]" , "Bot" ),
43+ "" ,
44+ id = "bot" ,
45+ ),
46+ ],
47+ )
48+ def test_thanker (httpserver : HTTPServer , author : DummyAuthor , expected : str ) -> None :
2049 org = "my_gh_org"
2150 repo = "my_gh_repo"
2251 base_url = httpserver .url_for ("/" )
@@ -73,12 +102,13 @@ def test_thanker(httpserver: HTTPServer) -> None:
73102 },
74103 },
75104 "author" : {
76- "id" : 101 ,
77- "login" : "jappleseed" ,
78- "url" : f"{ base_url } users/j.appleseed" ,
105+ "id" : author .id ,
106+ "login" : author .login ,
107+ "url" : f"{ base_url } { author .path } " ,
108+ "type" : author .type ,
79109 },
80110 },
81111 )
82112
83113 thanker = Thanker (f"{ org } /{ repo } " , base_url = base_url )
84- assert thanker .thanks_message (commit ) == " -- _**Thanks @jappleseed!**_"
114+ assert thanker .thanks_message (commit ) == expected
0 commit comments