Skip to content

Commit

Permalink
Adjust request testcases to the upcoming Request api change
Browse files Browse the repository at this point in the history
There is no need to compute the request creator, because it is
stored in the request xml. Moreover, the old computation yields
a wrong result (see issue openSUSE#286).
  • Loading branch information
marcus-h committed Apr 12, 2017
1 parent a271a33 commit 6965dc5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/request_fixtures/test_read_request1.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<request id="42">
<request creator="creator" id="42">
<action type="submit">
<source package="bar" project="foo" rev="1" />
<target package="bar" project="foobar" />
Expand Down
2 changes: 1 addition & 1 deletion tests/request_fixtures/test_read_request2.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<request id="123">
<request creator="creator" id="123">
<action type="submit">
<source package="abc" project="xyz" />
<options>
Expand Down
2 changes: 1 addition & 1 deletion tests/request_fixtures/test_request_list_view1.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<request id="62">
<request creator="Admin" id="62">
<action type="set_bugowner">
<target project="foo" />
<person name="buguser" />
Expand Down
2 changes: 1 addition & 1 deletion tests/request_fixtures/test_request_list_view2.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<request id="21">
<request creator="foobar" id="21">
<action type="set_bugowner">
<target project="foo" />
<person name="buguser" />
Expand Down
2 changes: 1 addition & 1 deletion tests/request_fixtures/test_request_str1.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<request id="123">
<request creator="creator" id="123">
<action type="submit">
<source package="abc" project="xyz" />
<target project="foo" />
Expand Down
20 changes: 10 additions & 10 deletions tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ def test_read_request2(self):
self.assertEqual(r.statehistory[0].when, '2010-12-11T00:00:00')
self.assertEqual(r.statehistory[0].who, 'creator')
self.assertEqual(r.statehistory[0].comment, '')
self.assertEqual(r.get_creator(), 'creator')
self.assertEqual(r.creator, 'creator')
self.assertTrue(len(r.statehistory) == 1)
self.assertTrue(len(r.reviews) == 1)
self.assertEqual(xml, r.to_str())

def test_read_request3(self):
"""read in a request (with an "empty" comment+description)"""
from xml.etree import cElementTree as ET
xml = """<request id="2">
xml = """<request creator="xyz" id="2">
<action type="set_bugowner">
<target project="foo" />
<person name="buguser" />
Expand All @@ -415,8 +415,8 @@ def test_read_request3(self):
self.assertEqual(r.description, '')
self.assertTrue(len(r.statehistory) == 0)
self.assertTrue(len(r.reviews) == 0)
self.assertEqual(r.get_creator(), 'xyz')
exp = """<request id="2">
self.assertEqual(r.creator, 'xyz')
exp = """<request creator="xyz" id="2">
<action type="set_bugowner">
<target project="foo" />
<person name="buguser" />
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_request_str1(self):
r = osc.core.Request()
r = osc.core.Request()
r.read(ET.fromstring(xml))
self.assertEqual(r.get_creator(), 'creator')
self.assertEqual(r.creator, 'creator')
exp = """\
Request: #123
Expand Down Expand Up @@ -496,7 +496,7 @@ def test_request_str2(self):
"""test the __str__ method"""
from xml.etree import cElementTree as ET
xml = """\
<request id="98765">
<request creator="creator" id="98765">
<action type="change_devel">
<source project="devprj" package="devpkg" />
<target project="foo" package="bar" />
Expand All @@ -508,7 +508,7 @@ def test_request_str2(self):
</request>"""
r = osc.core.Request()
r.read(ET.fromstring(xml))
self.assertEqual(r.get_creator(), 'creator')
self.assertEqual(r.creator, 'creator')
exp = """\
Request: #98765
Expand All @@ -527,7 +527,7 @@ def test_legacy_request(self):
"""load old-style submitrequest"""
from xml.etree import cElementTree as ET
xml = """\
<request id="1234" type="submit">
<request creator="olduser" id="1234" type="submit">
<submit>
<source package="baz" project="foobar" />
<target package="baz" project="foo" />
Expand All @@ -548,9 +548,9 @@ def test_legacy_request(self):
self.assertEqual(r.state.when, '2010-12-30T02:11:22')
self.assertEqual(r.state.who, 'olduser')
self.assertEqual(r.state.comment, '')
self.assertEqual(r.get_creator(), 'olduser')
self.assertEqual(r.creator, 'olduser')
exp = """\
<request id="1234">
<request creator="olduser" id="1234">
<action type="submit">
<source package="baz" project="foobar" />
<target package="baz" project="foo" />
Expand Down

0 comments on commit 6965dc5

Please sign in to comment.