Merge lp:~caio1982/capomastro/depstatus-1421337 into lp:capomastro

Proposed by Caio Begotti
Status: Merged
Approved by: Daniel Manrique
Approved revision: 209
Merged at revision: 201
Proposed branch: lp:~caio1982/capomastro/depstatus-1421337
Merge into: lp:capomastro
Diff against target: 138 lines (+29/-15)
6 files modified
capomastro/site/templatetags/capomastro_bootstrap.py (+7/-1)
capomastro/site/templatetags/tests/test_capomastro_bootstrap.py (+3/-2)
jenkins/models.py (+2/-1)
jenkins/tests/test_views.py (+1/-1)
projects/tests/test_views.py (+5/-4)
projects/views.py (+11/-6)
To merge this branch: bzr merge lp:~caio1982/capomastro/depstatus-1421337
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+263714@code.launchpad.net

Commit message

Improve how direct dependencies builds have their status shown in the detail view.

Description of the change

Address the problems of https://bugs.launchpad.net/capomastro/+bug/1421337 which basically have to do with how we display recently queued dependencies when someone requests a direct build of them (not via a project).

The original bug ticket has a screenshot showing the before and after these changes.

Some tests got changed because of the new default status for dependencies and because, well, we're not using the notifications bubbles texts in the tests anymore.

I have only tested these changes locally, not on Wendigo because PS4.5 is a bit overloaded now.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

Looks good to me, the "building" status is quite clear and less likely to get lost than the bubble.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'capomastro/site/templatetags/capomastro_bootstrap.py'
2--- capomastro/site/templatetags/capomastro_bootstrap.py 2014-03-21 10:45:10 +0000
3+++ capomastro/site/templatetags/capomastro_bootstrap.py 2015-07-02 19:45:24 +0000
4@@ -13,7 +13,13 @@
5 known_statuses = {
6 "SUCCESS": "success",
7 "FAILURE": "danger",
8- "ABORTED": "info"
9+ "ABORTED": "warning",
10+
11+ # not actual jenkins statuses but
12+ # these are useful to provide meaninful
13+ # information for users in the views
14+ "QUEUED": "info",
15+ "BUILDING": "info"
16 }
17 return known_statuses.get(value, "")
18
19
20=== modified file 'capomastro/site/templatetags/tests/test_capomastro_bootstrap.py'
21--- capomastro/site/templatetags/tests/test_capomastro_bootstrap.py 2014-03-20 16:17:58 +0000
22+++ capomastro/site/templatetags/tests/test_capomastro_bootstrap.py 2015-07-02 19:45:24 +0000
23@@ -15,8 +15,9 @@
24 "ABORTED" etc to a class suitable for Bootstrap tables.
25 """
26 for status, class_ in [
27- ("SUCCESS", "success"), ("ABORTED", "info"),
28- ("FAILURE", "danger"), ("", "")]:
29+ ("SUCCESS", "success"), ("ABORTED", "warning"),
30+ ("FAILURE", "danger"), ("BUILDING", "info"),
31+ ("QUEUED", "info"), ("", "")]:
32 self.assertEqual(class_, build_status_to_class(status))
33
34 def test_build_status_to_class_in_template(self):
35
36=== modified file 'jenkins/models.py'
37--- jenkins/models.py 2014-08-07 14:40:40 +0000
38+++ jenkins/models.py 2015-07-02 19:45:24 +0000
39@@ -77,7 +77,8 @@
40 duration = models.IntegerField(null=True)
41 url = models.CharField(max_length=255)
42 phase = models.CharField(max_length=25) # FINALIZED, STARTED, COMPLETED
43- status = models.CharField(max_length=255)
44+ # the default value here is only used a build had just been requested
45+ status = models.CharField(max_length=255, default='QUEUED')
46 console_log = models.TextField(blank=True, null=True, editable=False)
47 parameters = fields.JSONField(blank=True, null=True, editable=False)
48 created_at = models.DateTimeField(auto_now_add=True)
49
50=== modified file 'jenkins/tests/test_views.py'
51--- jenkins/tests/test_views.py 2014-11-29 13:10:09 +0000
52+++ jenkins/tests/test_views.py 2015-07-02 19:45:24 +0000
53@@ -102,7 +102,7 @@
54
55 self.assertEqual(1, Build.objects.count())
56 build = Build.objects.get(job=self.job, number=11)
57- self.assertEqual("", build.status)
58+ self.assertEqual("QUEUED", build.status)
59 self.assertEqual(Build.STARTED, build.phase)
60
61 def test_handle_started_notification_with_build_id(self):
62
63=== modified file 'projects/tests/test_views.py'
64--- projects/tests/test_views.py 2015-05-06 16:49:56 +0000
65+++ projects/tests/test_views.py 2015-07-02 19:45:24 +0000
66@@ -544,7 +544,8 @@
67
68 self.assertEqual(dependency, response.context["dependency"])
69 self.assertEqual([project], list(response.context["projects"]))
70- self.assertNotContains(response, "Dependency currently building")
71+ self.assertNotContains(response, "BUILDING")
72+ self.assertNotContains(response, "QUEUED")
73
74 self.assertEqual('', response.context["archiver"])
75 archive = ArchiveFactory.create(policy="cdimage", default=True)
76@@ -553,15 +554,15 @@
77
78 def test_dependency_detail_with_currently_building(self):
79 """
80- If the Dependency is currently building, we should get an info message
81- with this in the page.
82+ If the Dependency is currently building, we should have a
83+ proper status being shown in the build list of the page.
84 """
85 dependency = DependencyFactory.create()
86 BuildFactory.create(job=dependency.job, status="STARTED")
87 dependency_url = reverse("dependency_detail",
88 kwargs={"pk": dependency.pk})
89 response = self.app.get(dependency_url, user=self.user)
90- self.assertContains(response, "Dependency currently building")
91+ self.assertContains(response, "BUILDING")
92
93 def test_dependency_build(self):
94 """
95
96=== modified file 'projects/views.py'
97--- projects/views.py 2015-05-06 16:49:56 +0000
98+++ projects/views.py 2015-07-02 19:45:24 +0000
99@@ -378,13 +378,17 @@
100 context=context, page=self.request.GET.get('page'))
101 context["projects"] = Project.objects.filter(
102 dependencies=context["dependency"])
103- if context["dependency"].is_building:
104- messages.add_message(
105- self.request, messages.INFO,
106- "Dependency currently building")
107-
108 dependency = get_object_or_404(Dependency, pk=self.object.pk)
109 build_parameters = dependency.get_build_parameters()
110+
111+ if dependency.is_building:
112+ job = Build.objects.filter(job=dependency.job).first()
113+ job.status = u'BUILDING'
114+ # i was a bit unsure whether i should pass all the args again
115+ # and simply call save() or not, but i decided to only update one
116+ # field and keep it safe
117+ job.save(update_fields=['status'])
118+
119 context["default_build_parameters"] = [x for x in
120 parse_parameters_from_job(self.object.job.jobtype.config_xml)
121 if x["name"] != "BUILD_ID" and x["name"] not in build_parameters]
122@@ -404,6 +408,7 @@
123 messages.add_message(
124 self.request, messages.INFO,
125 "Build for '%s' queued." % dependency.name)
126+
127 url = reverse("dependency_detail", kwargs={"pk": dependency.pk})
128 return HttpResponseRedirect(url)
129
130@@ -487,7 +492,7 @@
131 return response
132
133 def get_success_url(self):
134- return reverse("home")
135+ return reverse("dependency_list")
136
137 def get_context_data(self, **kwargs):
138 """

Subscribers

People subscribed via source and target branches