def test_constructor(self) -> None: ywh = YesWeHackConfiguration( api_url='http://example.com', pat='60d8fac0-c0ee-496a-a153-298164615021', verify=True, programs=Programs([ Program( slug='1-pgm', bugtrackers_name=Bugtrackers([ 'bt1', 'bt2', ], ), ), ], ), ) self.assertEqual('http://example.com', ywh.api_url) self.assertEqual('60d8fac0-c0ee-496a-a153-298164615021', ywh.pat) self.assertEqual(first=True, second=ywh.verify) self.assertEqual('1-pgm', cast(Programs, ywh.programs)[0].slug) self.assertEqual( [ 'bt1', 'bt2', ], cast(Programs, ywh.programs)[0].bugtrackers_name, )
def test_validate_no_trackers(self) -> None: root = RootConfiguration( bugtrackers=Trackers(), yeswehack=YesWeHackConfigurations(my_ywh=YesWeHackConfiguration( api_url='http://example.com', login='******', password='******', oauth_args=OAuthSettings( client_id='client-id', client_secret='client-secret', redirect_uri='http://example.com/oauth/redirect', ), apps_headers=Headers({ 'X-YesWeHack-Apps': '123', }, ), verify=True, programs=Programs([ Program( slug='1-pgm', bugtrackers_name=Bugtrackers([ 'my_gitlab', 'my_github', ], ), ), ], ), ), ), ) with self.assertRaises(AttributesError): root.validate()
def test_validate_no_trackers(self) -> None: root = RootConfiguration( bugtrackers=Trackers(), yeswehack=YesWeHackConfigurations( my_ywh=YesWeHackConfiguration( api_url='http://example.com', pat='e2d00087-a2fa-4fe2-ac1c-7abf1da2a036', verify=True, programs=Programs( [ Program( slug='1-pgm', bugtrackers_name=Bugtrackers( [ 'my_gitlab', 'my_github', ], ), ), ], ), ), ), ) with self.assertRaises(AttributesError): root.validate()
def _build_configuration( self, tracker_key: str = 'tracker', ) -> RootConfiguration: return RootConfiguration( yeswehack=YesWeHackConfigurations(ywh_test=YesWeHackConfiguration( apps_headers=Headers(**{ 'X-YesWeHack-Apps': 'qwerty', }, ), login='******', password='******', programs=Programs(items=[ Program( slug='program1', bugtrackers_name=Bugtrackers([ tracker_key, ], ), ), ], ), ), ), bugtrackers=Trackers( **{ tracker_key: MyTrackerTrackerConfiguration(), }, ), )
def test_constructor(self) -> None: ywh = YesWeHackConfiguration( api_url='http://example.com', apps_headers=Headers(foo='bar', ), login='******', password='******', oauth_args=OAuthSettings( client_id='client-id', client_secret='client-secret', redirect_uri='http://example.com/oauth/redirect', ), verify=True, programs=Programs([ Program( slug='1-pgm', bugtrackers_name=Bugtrackers([ 'bt1', 'bt2', ], ), ), ], ), ) self.assertEqual('http://example.com', ywh.api_url) self.assertEqual( dict(foo='bar', ), ywh.apps_headers, ) self.assertEqual('*****@*****.**', ywh.login) self.assertEqual('my-password', ywh.password) self.assertEqual('client-id', cast(OAuthSettings, ywh.oauth_args).client_id) self.assertEqual('client-secret', cast(OAuthSettings, ywh.oauth_args).client_secret) self.assertEqual('http://example.com/oauth/redirect', cast(OAuthSettings, ywh.oauth_args).redirect_uri) self.assertEqual(first=True, second=ywh.verify) self.assertEqual('1-pgm', cast(Programs, ywh.programs)[0].slug) self.assertEqual( [ 'bt1', 'bt2', ], cast(Programs, ywh.programs)[0].bugtrackers_name, )
def test_validate(self) -> None: root = RootConfiguration( bugtrackers=Trackers( my_gitlab=GitLabConfiguration( token='gl-token', project='my-project', ), my_github=GitHubConfiguration( token='gh-token', project='project', ), ), yeswehack=YesWeHackConfigurations(my_ywh=YesWeHackConfiguration( api_url='http://example.com', login='******', password='******', oauth_args=OAuthSettings( client_id='client-id', client_secret='client-secret', redirect_uri='http://example.com/oauth/redirect', ), apps_headers=Headers({ 'X-YesWeHack-Apps': '123', }, ), verify=True, programs=Programs([ Program( slug='1-pgm', bugtrackers_name=Bugtrackers([ 'my_gitlab', ], ), ), Program( slug='1-pgm', bugtrackers_name=Bugtrackers([ 'my_github', ], ), ), ], ), ), ), ) root.validate()
def test_validate(self) -> None: root = RootConfiguration( bugtrackers=Trackers( my_gitlab=GitLabConfiguration( token='gl-token', project='my-project', ), my_github=GitHubConfiguration( token='gh-token', project='project', ), ), yeswehack=YesWeHackConfigurations( my_ywh=YesWeHackConfiguration( api_url='http://example.com', pat='e2d00087-a2fa-4fe2-ac1c-7abf1da2a036', verify=True, programs=Programs( [ Program( slug='1-pgm', bugtrackers_name=Bugtrackers( [ 'my_gitlab', ], ), ), Program( slug='1-pgm', bugtrackers_name=Bugtrackers( [ 'my_github', ], ), ), ], ), ), ), ) root.validate()