From 3d07bd8460c4d88ecf39a35ee1a67a9f26685f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 11 Sep 2014 14:34:22 +0200 Subject: [PATCH] - fix description rendering in history elements --- NEWS | 3 +++ osc/core.py | 19 +++++++++++++++++-- tests/request_fixtures/test_read_request1.xml | 3 ++- tests/request_fixtures/test_read_request2.xml | 4 +++- .../test_request_list_view2.xml | 8 ++++++-- tests/test_request.py | 8 +++----- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 825da9f6..abeea234 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +0.149 + - + 0.148 - support new history including review history of OBS 2.6 - display request priorities, if important or critical diff --git a/osc/core.py b/osc/core.py index 0a7b2b22..163d6487 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5,7 +5,7 @@ from __future__ import print_function -__version__ = '0.148' +__version__ = '0.148git' # __store_version__ is to be incremented when the format of the working copy # "store" changes in an incompatible way. Please add any needed migration @@ -2357,6 +2357,10 @@ class AbstractState: """return data from tag""" raise NotImplementedError() + def get_description(self): + """return data from tag""" + raise NotImplementedError() + def to_xml(self): """serialize object to XML""" root = ET.Element(self.get_node_name()) @@ -2364,6 +2368,8 @@ class AbstractState: val = getattr(self, attr) if not val is None: root.set(attr, val) + if self.get_description(): + ET.SubElement(root, 'description').text = self.get_description() if self.get_comment(): ET.SubElement(root, 'comment').text = self.get_comment() return root @@ -2400,6 +2406,9 @@ class ReviewState(AbstractState): def get_comment(self): return self.comment + def get_description(self): + return None + class RequestHistory(AbstractState): """Represents a history element of a request""" @@ -2420,7 +2429,10 @@ class RequestHistory(AbstractState): self.comment = history_node.find('comment').text.strip() def get_node_attrs(self): - return ('who', 'when', 'description') + return ('who', 'when') + + def get_description(self): + return self.description def get_comment(self): return self.comment @@ -2450,6 +2462,9 @@ class RequestState(AbstractState): def get_comment(self): return self.comment + def get_description(self): + return None + class Action: """ diff --git a/tests/request_fixtures/test_read_request1.xml b/tests/request_fixtures/test_read_request1.xml index 87807814..af699507 100644 --- a/tests/request_fixtures/test_read_request1.xml +++ b/tests/request_fixtures/test_read_request1.xml @@ -7,7 +7,8 @@ - + + Create Request foobar title of the request diff --git a/tests/request_fixtures/test_read_request2.xml b/tests/request_fixtures/test_read_request2.xml index 52d5808b..2916955e 100644 --- a/tests/request_fixtures/test_read_request2.xml +++ b/tests/request_fixtures/test_read_request2.xml @@ -15,5 +15,7 @@ review start - + + Created request + diff --git a/tests/request_fixtures/test_request_list_view2.xml b/tests/request_fixtures/test_request_list_view2.xml index 976c1553..ae9213aa 100644 --- a/tests/request_fixtures/test_request_list_view2.xml +++ b/tests/request_fixtures/test_request_list_view2.xml @@ -4,8 +4,12 @@ - - + + Created Request + + + Review Approved + This is a simple request with a lot of ... ... text and other stuff. This request also contains a description. This is useful to diff --git a/tests/test_request.py b/tests/test_request.py index 5b941c06..3a3f3256 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -342,7 +342,6 @@ class TestRequest(OscTestCase): self.assertEqual(r.state.when, '2010-12-27T01:36:29') self.assertEqual(r.state.who, 'user1') self.assertEqual(r.state.comment, '') - self.assertEqual(r.statehistory[0].name, 'new') self.assertEqual(r.statehistory[0].when, '2010-12-13T13:02:03') self.assertEqual(r.statehistory[0].who, 'creator') self.assertEqual(r.statehistory[0].comment, 'foobar') @@ -382,7 +381,6 @@ class TestRequest(OscTestCase): self.assertEqual(r.reviews[0].who, 'abc') self.assertEqual(r.reviews[0].comment, 'review start') self.assertTrue(r.reviews[0].by_user is None) - self.assertEqual(r.statehistory[0].name, 'new') self.assertEqual(r.statehistory[0].when, '2010-12-11T00:00:00') self.assertEqual(r.statehistory[0].who, 'creator') self.assertEqual(r.statehistory[0].comment, '') @@ -455,7 +453,7 @@ class TestRequest(OscTestCase): exp = """\ 21 State:accepted By:foobar When:2010-12-29T16:37:45 set_bugowner: buguser foo - From: new(user) -> review(foobar) + From: Created Request: user -> Review Approved: foobar Descr: This is a simple request with a lot of ... ... text and other stuff. This request also contains a description. This is useful to describe the request. blabla blabla\n""" @@ -488,8 +486,8 @@ Comment: currently in review Review: accepted Group: group1 2010-12-29T00:11:22 abc accepted new Group: group1 2010-12-28T00:11:22 abc review start -History: revoked 2010-12-12T00:00:00 creator - new 2010-12-11T00:00:00 creator""" +History: 2010-12-12T00:00:00 creator revoked + 2010-12-11T00:00:00 creator new""" self.assertEqual(exp, str(r)) def test_request_str2(self):