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')
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_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())
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())
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