1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

Adjust request testcases to the upcoming Request api change

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 #286).
This commit is contained in:
Marcus Huewe 2017-04-12 12:55:16 +02:00
parent a271a33a53
commit 6965dc5cd4
6 changed files with 15 additions and 15 deletions

View File

@ -1,4 +1,4 @@
<request id="42"> <request creator="creator" id="42">
<action type="submit"> <action type="submit">
<source package="bar" project="foo" rev="1" /> <source package="bar" project="foo" rev="1" />
<target package="bar" project="foobar" /> <target package="bar" project="foobar" />

View File

@ -1,4 +1,4 @@
<request id="123"> <request creator="creator" id="123">
<action type="submit"> <action type="submit">
<source package="abc" project="xyz" /> <source package="abc" project="xyz" />
<options> <options>

View File

@ -1,4 +1,4 @@
<request id="62"> <request creator="Admin" id="62">
<action type="set_bugowner"> <action type="set_bugowner">
<target project="foo" /> <target project="foo" />
<person name="buguser" /> <person name="buguser" />

View File

@ -1,4 +1,4 @@
<request id="21"> <request creator="foobar" id="21">
<action type="set_bugowner"> <action type="set_bugowner">
<target project="foo" /> <target project="foo" />
<person name="buguser" /> <person name="buguser" />

View File

@ -1,4 +1,4 @@
<request id="123"> <request creator="creator" id="123">
<action type="submit"> <action type="submit">
<source package="abc" project="xyz" /> <source package="abc" project="xyz" />
<target project="foo" /> <target project="foo" />

View File

@ -384,7 +384,7 @@ class TestRequest(OscTestCase):
self.assertEqual(r.statehistory[0].when, '2010-12-11T00:00:00') self.assertEqual(r.statehistory[0].when, '2010-12-11T00:00:00')
self.assertEqual(r.statehistory[0].who, 'creator') self.assertEqual(r.statehistory[0].who, 'creator')
self.assertEqual(r.statehistory[0].comment, '') 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.statehistory) == 1)
self.assertTrue(len(r.reviews) == 1) self.assertTrue(len(r.reviews) == 1)
self.assertEqual(xml, r.to_str()) self.assertEqual(xml, r.to_str())
@ -392,7 +392,7 @@ class TestRequest(OscTestCase):
def test_read_request3(self): def test_read_request3(self):
"""read in a request (with an "empty" comment+description)""" """read in a request (with an "empty" comment+description)"""
from xml.etree import cElementTree as ET from xml.etree import cElementTree as ET
xml = """<request id="2"> xml = """<request creator="xyz" id="2">
<action type="set_bugowner"> <action type="set_bugowner">
<target project="foo" /> <target project="foo" />
<person name="buguser" /> <person name="buguser" />
@ -415,8 +415,8 @@ class TestRequest(OscTestCase):
self.assertEqual(r.description, '') self.assertEqual(r.description, '')
self.assertTrue(len(r.statehistory) == 0) self.assertTrue(len(r.statehistory) == 0)
self.assertTrue(len(r.reviews) == 0) self.assertTrue(len(r.reviews) == 0)
self.assertEqual(r.get_creator(), 'xyz') self.assertEqual(r.creator, 'xyz')
exp = """<request id="2"> exp = """<request creator="xyz" id="2">
<action type="set_bugowner"> <action type="set_bugowner">
<target project="foo" /> <target project="foo" />
<person name="buguser" /> <person name="buguser" />
@ -466,7 +466,7 @@ class TestRequest(OscTestCase):
r = osc.core.Request() r = osc.core.Request()
r = osc.core.Request() r = osc.core.Request()
r.read(ET.fromstring(xml)) r.read(ET.fromstring(xml))
self.assertEqual(r.get_creator(), 'creator') self.assertEqual(r.creator, 'creator')
exp = """\ exp = """\
Request: #123 Request: #123
@ -496,7 +496,7 @@ History: 2010-12-12T00:00:00 creator revoked
"""test the __str__ method""" """test the __str__ method"""
from xml.etree import cElementTree as ET from xml.etree import cElementTree as ET
xml = """\ xml = """\
<request id="98765"> <request creator="creator" id="98765">
<action type="change_devel"> <action type="change_devel">
<source project="devprj" package="devpkg" /> <source project="devprj" package="devpkg" />
<target project="foo" package="bar" /> <target project="foo" package="bar" />
@ -508,7 +508,7 @@ History: 2010-12-12T00:00:00 creator revoked
</request>""" </request>"""
r = osc.core.Request() r = osc.core.Request()
r.read(ET.fromstring(xml)) r.read(ET.fromstring(xml))
self.assertEqual(r.get_creator(), 'creator') self.assertEqual(r.creator, 'creator')
exp = """\ exp = """\
Request: #98765 Request: #98765
@ -527,7 +527,7 @@ Comment: <no comment>"""
"""load old-style submitrequest""" """load old-style submitrequest"""
from xml.etree import cElementTree as ET from xml.etree import cElementTree as ET
xml = """\ xml = """\
<request id="1234" type="submit"> <request creator="olduser" id="1234" type="submit">
<submit> <submit>
<source package="baz" project="foobar" /> <source package="baz" project="foobar" />
<target package="baz" project="foo" /> <target package="baz" project="foo" />
@ -548,9 +548,9 @@ Comment: <no comment>"""
self.assertEqual(r.state.when, '2010-12-30T02:11:22') self.assertEqual(r.state.when, '2010-12-30T02:11:22')
self.assertEqual(r.state.who, 'olduser') self.assertEqual(r.state.who, 'olduser')
self.assertEqual(r.state.comment, '') self.assertEqual(r.state.comment, '')
self.assertEqual(r.get_creator(), 'olduser') self.assertEqual(r.creator, 'olduser')
exp = """\ exp = """\
<request id="1234"> <request creator="olduser" id="1234">
<action type="submit"> <action type="submit">
<source package="baz" project="foobar" /> <source package="baz" project="foobar" />
<target package="baz" project="foo" /> <target package="baz" project="foo" />