def test_get_tracker_client_not_registered(self) -> None:
     TrackerConfiguration.register_subtype(
         subtype_name='my',
         subtype_class=MyConfiguration,
     )
     factory = TrackerClientsFactory()
     with self.assertRaises(CoreException):
         factory.get_tracker_client(configuration=MyConfiguration(), )
 def test_get_tracker_client(self) -> None:
     TrackerConfiguration.register_subtype(
         subtype_name='my',
         subtype_class=MyConfiguration,
     )
     TrackerClientClassesRegistry.register_tracker_client_class(
         configuration_class=MyConfiguration,
         client_class=MyTrackerClient,
     )
     factory = TrackerClientsFactory()
     factory.get_tracker_client(configuration=MyConfiguration(), )
예제 #3
0
    def test_register_tracker(self) -> None:
        class MyTracker(TrackerConfiguration):  # noqa: WPS431
            prop1 = Attribute.create(
                value_type=str,
                required=True,
            )

        TrackerConfiguration.register_subtype('my-tracker', MyTracker)

        t1 = MyTracker()
        t1.prop1 = 'foo'
        self.assertEqual(t1.export(), dict(
            type='my-tracker',
            prop1='foo',
        ))
예제 #4
0
    def test_trackers_loose_cast(self) -> None:
        class ATracker(TrackerConfiguration):  # noqa: WPS431
            name = Attribute.create(value_type=str, )

            def __init__(
                self,
                name: Optional[str],
            ):
                super().__init__()
                self.name = name

        TrackerConfiguration.register_subtype('a-tracker', ATracker)

        class CTracker(TrackerConfiguration):  # noqa: WPS431
            description = Attribute.create(value_type=str, )

            def __init__(
                self,
                description: Optional[str],
            ):
                super().__init__()
                self.description = description

        TrackerConfiguration.register_subtype('c-tracker', CTracker)

        trackers = Trackers(
            a=dict(
                type='a-tracker',
                name='my tracker',
            ),
            c=dict(
                type='c-tracker',
                description='this a tracker of type c',
            ),
        )
        self.assertIsInstance(trackers['a'], ATracker)
        self.assertEqual('my tracker', cast(ATracker, trackers['a']).name)
        self.assertIsInstance(trackers['c'], CTracker)
        self.assertEqual('this a tracker of type c',
                         cast(CTracker, trackers['c']).description)
예제 #5
0
                    message='Validation error',
                    errors={},
                    context=self,
                )
            super_error.errors.update(errors)

        if super_error:
            raise super_error

    def _ensure_login_password(self, ) -> Dict[str, MissingAttributeError]:
        errors = {}
        if self.login is None:
            errors['login'] = MissingAttributeError(
                message=
                "Expecting value for attribute 'login' when 'github_on_cdn' is True",
                context=self,
            )
        if self.password is None:
            errors['password'] = MissingAttributeError(
                message=
                "Expecting value for attribute 'password' when 'github_on_cdn' is True",
                context=self,
            )
        return errors


TrackerConfiguration.register_subtype(
    subtype_name='github',
    subtype_class=GitHubConfiguration,
)
예제 #6
0
 def test_registered(self) -> None:
     tracker = TrackerConfiguration(type='gitlab')
     self.assertIsInstance(tracker, GitLabConfiguration)
예제 #7
0
 def test_registered(self) -> None:
     tracker = TrackerConfiguration(type='jira')
     self.assertIsInstance(tracker, JiraConfiguration)
예제 #8
0
 def setUp(self) -> None:
     TrackerConfiguration.register_subtype(
         subtype_name='my',
         subtype_class=MyTrackerTrackerConfiguration,
     )
예제 #9
0
        host: Optional[Text] = None,
        login: Optional[Text] = None,
        password: Optional[Text] = None,
        use_ssl: Optional[bool] = None,
        verify: Optional[bool] = None,
        **kwargs: Any,
    ):
        """
        Initialize the configuration.

        Args:
            host: a ServiceNow instance host
            login: a ServiceNow user login
            password: a ServiceNow user password
            use_ssl: a flag indicating whether to use SSL/TLS connection
            verify: a flag indicating whether to check SSL/TLS connection
            kwargs: keyword arguments
        """
        super().__init__(**kwargs)
        self.host = host
        self.login = login
        self.password = password
        self.use_ssl = use_ssl
        self.verify = verify


TrackerConfiguration.register_subtype(
    subtype_name='servicenow',
    subtype_class=ServiceNowConfiguration,
)
예제 #10
0
        issue_closed_status: Optional[Text] = None,
        **kwargs: Any,
    ):
        """
        Initialize the configuration.

        Args:
            url: a Jira API URL
            login: a Jira API user login
            password: a Jira API user password
            project: a Jira project name
            verify: a flag indicating whether to check SSL/TLS connection
            issuetype: a Jira issue type
            issue_closed_status: a Jira name when the issue is closed
            kwargs: keyword arguments
        """
        super().__init__(**kwargs)
        self.url = url
        self.login = login
        self.password = password
        self.project = project
        self.verify = verify
        self.issuetype = issuetype
        self.issue_closed_status = issue_closed_status


TrackerConfiguration.register_subtype(
    subtype_name='jira',
    subtype_class=JiraConfiguration,
)