Merge lp:~ltrager/maas/lp1598461_2.0 into lp:maas/2.0

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 5149
Proposed branch: lp:~ltrager/maas/lp1598461_2.0
Merge into: lp:maas/2.0
Diff against target: 75 lines (+36/-4)
2 files modified
src/maas/settings.py (+3/-3)
src/maasserver/views/tests/test_images.py (+33/-1)
To merge this branch: bzr merge lp:~ltrager/maas/lp1598461_2.0
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+299594@code.launchpad.net

Commit message

Show image last update using the time format consistent with other areas of the MAAS UI

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :

Merge has no changes, approved in other MP

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maas/settings.py'
2--- src/maas/settings.py 2016-06-07 19:59:49 +0000
3+++ src/maas/settings.py 2016-07-08 18:17:11 +0000
4@@ -156,9 +156,9 @@
5 # to load the internationalization machinery.
6 USE_I18N = True
7
8-# If you set this to False, Django will not format dates, numbers and
9-# calendars according to the current locale
10-USE_L10N = True
11+# Set the datetime format Django uses in templates to show the time in UTC.
12+# The format is consistent with what the websockets use.
13+DATETIME_FORMAT = 'D, d M. o H:i:s'
14
15 # Absolute filesystem path to the directory that will hold user-uploaded files.
16 # Example: "/home/media/media.lawrence.com/media/"
17
18=== modified file 'src/maasserver/views/tests/test_images.py'
19--- src/maasserver/views/tests/test_images.py 2016-06-10 17:54:17 +0000
20+++ src/maasserver/views/tests/test_images.py 2016-07-08 18:17:11 +0000
21@@ -308,7 +308,11 @@
22 last_update = doc.cssselect(
23 'table#other-resources > tbody > '
24 'tr > td')[5].text_content().strip()
25- self.assertNotEqual('not synced', last_update)
26+ dt = datetime.datetime.strptime(last_update, '%a, %d %b. %Y %H:%M:%S')
27+ # TimestampedModel includes microseconds which we don't print. To
28+ # confirm the right time is returned its easiest to just compare the
29+ # ctimes
30+ self.assertEquals(cache.updated.ctime(), dt.ctime())
31
32 def test_shows_number_of_nodes_for_synced_resource(self):
33 self.client_log_in(as_admin=True)
34@@ -480,6 +484,20 @@
35 1, len(delete_btn),
36 "Didn't show delete button for generated image.")
37
38+ def test_shows_last_update_time_for_synced_resource(self):
39+ self.client_log_in(as_admin=True)
40+ resource = self.make_generated_resource()
41+ response = self.client.get(reverse('images'))
42+ doc = fromstring(response.content)
43+ last_update = doc.cssselect(
44+ 'table#generated-resources > tbody > '
45+ 'tr > td')[5].text_content().strip()
46+ dt = datetime.datetime.strptime(last_update, '%a, %d %b. %Y %H:%M:%S')
47+ # TimestampedModel includes microseconds which we don't print. To
48+ # confirm the right time is returned its easiest to just compare the
49+ # ctimes
50+ self.assertEquals(resource.updated.ctime(), dt.ctime())
51+
52 def test_hides_delete_button_for_generated_resource_when_not_admin(self):
53 self.client_log_in()
54 self.make_generated_resource()
55@@ -552,6 +570,20 @@
56 'table#uploaded-resources > tbody > tr > td')[1].text_content()
57 self.assertEqual(name, name_col.strip())
58
59+ def test_shows_last_update_time_for_synced_resource(self):
60+ self.client_log_in(as_admin=True)
61+ resource = self.make_uploaded_resource()
62+ response = self.client.get(reverse('images'))
63+ doc = fromstring(response.content)
64+ last_update = doc.cssselect(
65+ 'table#uploaded-resources > tbody > '
66+ 'tr > td')[5].text_content().strip()
67+ dt = datetime.datetime.strptime(last_update, '%a, %d %b. %Y %H:%M:%S')
68+ # TimestampedModel includes microseconds which we don't print. To
69+ # confirm the right time is returned its easiest to just compare the
70+ # ctimes
71+ self.assertEquals(resource.updated.ctime(), dt.ctime())
72+
73 def test_shows_delete_button_for_uploaded_resource(self):
74 self.client_log_in(as_admin=True)
75 self.make_uploaded_resource()

Subscribers

People subscribed via source and target branches

to all changes: