@@ -137,6 +137,73 @@ def test_smoke(self) -> None:
137137 assert passgithelper .EntryNameExtractor ().get_value ("foo/bar" , []) == "bar"
138138
139139
140+ class TestStaticUsernameExtractor :
141+ def test_extracts_username_from_config (self ) -> None :
142+ config = configparser .ConfigParser ()
143+ config .read_string (
144+ """[test]
145+ 146+ """
147+ )
148+
149+ extractor = passgithelper .StaticUsernameExtractor ()
150+ extractor .configure (config ["test" ])
151+
152+ assert (
153+ extractor .
get_value (
"any/entry" , [
"any" ,
"lines" ])
== "[email protected] " 154+ )
155+
156+ def test_returns_none_when_no_username_configured (self ) -> None :
157+ config = configparser .ConfigParser ()
158+ config .read_string (
159+ """[test]
160+ target = some/target
161+ """
162+ )
163+
164+ extractor = passgithelper .StaticUsernameExtractor ()
165+ extractor .configure (config ["test" ])
166+
167+ assert extractor .get_value ("any/entry" , ["any" , "lines" ]) is None
168+
169+ def test_inherits_from_default_section (self ) -> None :
170+ config = configparser .ConfigParser ()
171+ config .read_string (
172+ """[DEFAULT]
173+ 174+
175+ [test]
176+ target = some/target
177+ """
178+ )
179+
180+ extractor = passgithelper .StaticUsernameExtractor ()
181+ extractor .configure (config ["test" ])
182+
183+ assert (
184+ extractor .
get_value (
"any/entry" , [
"any" ,
"lines" ])
== "[email protected] " 185+ )
186+
187+ def test_section_overrides_default (self ) -> None :
188+ config = configparser .ConfigParser ()
189+ config .read_string (
190+ """[DEFAULT]
191+ 192+
193+ [test]
194+ target = some/target
195+ 196+ """
197+ )
198+
199+ extractor = passgithelper .StaticUsernameExtractor ()
200+ extractor .configure (config ["test" ])
201+
202+ assert (
203+ extractor .
get_value (
"any/entry" , [
"any" ,
"lines" ])
== "[email protected] " 204+ )
205+
206+
140207@pytest .mark .parametrize (
141208 "helper_config" ,
142209 [
0 commit comments