예제 #1
0
 def get_data(self):
     print("checking %s" % self.server_config.url)
     try:
         data = self.connection.connect(self.server_config, self.timeout)
     except Exception as ex:
         print(ex)
         return Response(
             ContinuousIntegrationServer(self.server_config.url, [], True),
             ex)
     dom = minidom.parseString(data)
     print("processed %s" % self.server_config.url)
     projects = []
     for node in dom.getElementsByTagName('Project'):
         projects.append(
             Project(
                 self.server_config.url, self.server_config.prefix,
                 self.server_config.timezone, {
                     'name': node.getAttribute('name'),
                     'lastBuildStatus':
                     node.getAttribute('lastBuildStatus'),
                     'lastBuildLabel': node.getAttribute('lastBuildLabel'),
                     'activity': node.getAttribute('activity'),
                     'url': node.getAttribute('webUrl'),
                     'lastBuildTime': node.getAttribute('lastBuildTime')
                 }))
     return Response(
         ContinuousIntegrationServer(self.server_config.url, projects))
예제 #2
0
    def get_data(self) -> Response:
        print("checking %s" % self.server_config.url)
        try:
            headers = {}
            if self.server_config.authentication_type == ServerConfig.AUTH_BEARER_TOKEN:
                headers['Authorization'] = 'Bearer %s' % self.server_config.password

            data = self.connection.connect(self.server_config, self.timeout, headers)
        except Exception as ex:
            print(ex)
            return Response(ContinuousIntegrationServer(self.server_config.url, [], True), ex)
        dom = minidom.parseString(data)
        print("processed %s" % self.server_config.url)
        projects = []
        for node in dom.getElementsByTagName('Project'):
            projects.append(Project(
                self.server_config.url,
                self.server_config.prefix,
                self.server_config.timezone,
                {
                    'name': node.getAttribute('name'), 'lastBuildStatus': node.getAttribute('lastBuildStatus'),
                    'lastBuildLabel': node.getAttribute('lastBuildLabel'), 'activity': node.getAttribute('activity'),
                    'url': node.getAttribute('webUrl'), 'lastBuildTime': node.getAttribute('lastBuildTime')
                }))
        return Response(ContinuousIntegrationServer(self.server_config.url, projects))
예제 #3
0
 def test_should_mark_failed_if_even_one_failed_across_servers(self):
     project1 = ProjectBuilder({'name': 'a', 'lastBuildStatus': 'Success', 'activity': 'Sleeping'}).build()
     project2 = ProjectBuilder({'name': 'a', 'lastBuildStatus': 'Failure', 'activity': 'Sleeping'}).build()
     status = OverallIntegrationStatus([
         ContinuousIntegrationServer("url1", [project1]),
         ContinuousIntegrationServer('url2', [project2])
     ])
     self.assertEquals('Failure.Sleeping', status.get_build_status())
def test_should_return_notifications(mocker):
    old_projects = [
        ProjectBuilder({
            'name': 'proj1',
            'lastBuildStatus': 'Success',
            'activity': 'Sleeping',
            'url': 'someurl',
            'lastBuildLabel': '1',
            'lastBuildTime': '2009-05-29T13:54:07'
        }).build(),
        ProjectBuilder({
            'name': 'Successbuild',
            'lastBuildStatus': 'Failure',
            'activity': 'Sleeping',
            'url': 'someurl',
            'lastBuildLabel': '10',
            'lastBuildTime': '2009-05-29T13:54:37'
        }).build()
    ]
    new_projects = [
        ProjectBuilder({
            'name': 'proj1',
            'lastBuildStatus': 'Failure',
            'activity': 'Sleeping',
            'url': 'someurl',
            'lastBuildLabel': '2',
            'lastBuildTime': '2009-05-29T13:54:07'
        }).build(),
        ProjectBuilder({
            'name': 'Successbuild',
            'lastBuildStatus': 'Success',
            'activity': 'Sleeping',
            'url': 'someurl',
            'lastBuildLabel': '11',
            'lastBuildTime': '2009-05-29T13:54:47'
        }).build()
    ]
    old = OverallIntegrationStatus(
        [ContinuousIntegrationServer('url', old_projects)])
    new = OverallIntegrationStatus(
        [ContinuousIntegrationServer('url', new_projects)])

    class NotificationFake(object):
        def __init__(self):
            pass

        def show_message(self, **kwargs):
            print kwargs

    m = mocker.patch.object(NotificationFake, 'show_message')

    notification = ProjectStatusNotification(ConfigBuilder().build(), old, new,
                                             NotificationFake())
    notification.show_notifications()

    m.assert_any_call('Broken builds', 'proj1')
    m.assert_any_call('Fixed builds', 'Successbuild')
예제 #5
0
    def test_should_remove_excluded_projects(self):
        project1 = ProjectBuilder({'name': 'a'}).build()
        project2 = ProjectBuilder({'name': 'b'}).build()

        server = FilteredContinuousIntegrationServer(ContinuousIntegrationServer("someurl", [project1, project2]), ['a'])

        self.assertEquals([project2], server.get_projects())
예제 #6
0
    def test_prefix_shouldnt_affect_exclusion(self):
        project1 = ProjectBuilder({'name': 'a'}).prefix('s1').build()
        project2 = ProjectBuilder({'name': 'b'}).prefix('s1').build()

        server = FilteredContinuousIntegrationServer(ContinuousIntegrationServer("someurl", [project1, project2]), ['a'])

        self.assertEquals([project2], server.get_projects())
예제 #7
0
class ProjectLoader(object):
    def __init__(self, server_config, timeout, connection=HttpConnection()):
        self.server_config = server_config
        self.timeout = timeout
        self.connection = connection

    def get_data(self):
        print "checking %s" % self.server_config.url
        try:
            data = self.connection.connect(self.server_config, self.timeout)
        except Exception, ex:
            print ex
            return Response(
                ContinuousIntegrationServer(self.server_config.url, [], True),
                ex)
        dom = minidom.parse(data)
        print "processed %s" % self.server_config.url
        projects = []
        for node in dom.getElementsByTagName('Project'):
            projects.append(
                Project(
                    self.server_config.url, self.server_config.prefix,
                    self.server_config.timezone, {
                        'name': node.getAttribute('name'),
                        'lastBuildStatus':
                        node.getAttribute('lastBuildStatus'),
                        'lastBuildLabel': node.getAttribute('lastBuildLabel'),
                        'activity': node.getAttribute('activity'),
                        'url': node.getAttribute('webUrl'),
                        'lastBuildTime': node.getAttribute('lastBuildTime')
                    }))
        return Response(
            ContinuousIntegrationServer(self.server_config.url, projects))
예제 #8
0
 def get_data(self):
     print "checking %s" % self.server_config.url
     try:
         data = self.connection.connect(self.server_config, self.timeout)
     except Exception, ex:
         print ex
         return Response(
             ContinuousIntegrationServer(self.server_config.url, [], True),
             ex)
예제 #9
0
 def test_should_identify_failing_builds(self):
     project1 = ProjectBuilder({
         'name': 'a',
         'lastBuildStatus': 'Success',
         'activity': 'Sleeping'
     }).build()
     project2 = ProjectBuilder({
         'name': 'a',
         'lastBuildStatus': 'Failure',
         'activity': 'Sleeping'
     }).build()
     status = OverallIntegrationStatus(
         [ContinuousIntegrationServer("someurl", [project1, project2])])
     self.assertEqual([project2], status.get_failing_builds())
예제 #10
0
 def test_should_consolidate_build_status(self):
     project1 = ProjectBuilder({
         'name': 'a',
         'lastBuildStatus': 'Success',
         'activity': 'Sleeping'
     }).build()
     project2 = ProjectBuilder({
         'name': 'a',
         'lastBuildStatus': 'Success',
         'activity': 'Sleeping'
     }).build()
     status = OverallIntegrationStatus(
         [ContinuousIntegrationServer("someurl", [project1, project2])])
     self.assertEqual('Success.Sleeping', status.get_build_status())
예제 #11
0
def test_should_update_tooltip_on_poll(qtbot):
    conf = ConfigBuilder().build()
    widget = AppUi(QtWidgets.QWidget(), conf, BuildIcons())
    qtbot.addWidget(widget)
    project1 = ProjectBuilder({
        'name': 'a',
        'lastBuildStatus': 'Success',
        'activity': 'Sleeping',
        'lastBuildTime': '2016-09-17 11:31:12'
    }).build()
    servers = [ContinuousIntegrationServer('someurl', [project1])]

    widget.update_projects(OverallIntegrationStatus(servers))

    assert re.compile("Last checked: \d{4}-\d\d-\d\d \d\d:\d\d:\d\d").match(
        str(widget.tray.toolTip())) is not None