Refactor functional tests
Bug #1395191 reported by
Victoria Martinez de la Cruz
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zaqar |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Functional tests should be refactored in order to avoid code duplication.
A way to fix it would be to move the common tests from v1/ and v1_1/ to the parent location and simply specialize the changes in v1/ and v1_1/.
Changed in zaqar: | |
assignee: | nobody → Victoria Martínez de la Cruz (vkmc) |
Changed in zaqar: | |
status: | New → Invalid |
assignee: | Victoria Martinez de la Cruz (vkmc) → nobody |
To post a comment you must log in.
Just to illustrate my point... this is the diff of test_messages.py for v1 and v1_1
1c1 base.V1Function alTestBase) : base.V1_ 1FunctionalTest Base): cfg.zaqar. url, cfg.zaqar. url, put(self. queue_url) create_ zaqar_headers( self.cfg) put(self. queue_url) # Create the queue delete( self.queue_ url) delete( self.queue_ url) # Remove the queue :[{{"body" : "{0}", "ttl": 300}},' create_ message_ body(messagecou nt=1) create_ message_ body_v1_ 1(messagecount= 1) ][0]['body' ] l(result. status_ code, 204) l(result. status_ code, 200) create_ message_ body(messagecou nt=message_ count) create_ message_ body_v1_ 1(messagecount= message_ count) json()[ i]['body' ] result. json()) )] json()[ 'messages' ]] count)] default_ ttl(self) : create_ message_ body_v1_ 1(messagecount= 1, post(data= doc) l(result. status_ code, 201) json()[ 'resources' ][0] get(url) l(result. status_ code, 200) json()[ 'ttl'] l(default_ ...
< # Copyright (c) 2013 Rackspace, Inc.
---
> # Copyright (c) 2014 Rackspace, Inc.
27,29c27,28
< class TestMessages(
<
< """Tests for Messages."""
---
> class TestMessages(
> """Message Tests Specific to V1.1."""
36c35
< self.queue = uuid.uuid1()
---
> self.queue = uuid.uuid1() # Generate a random queue ID
38,40c37,39
< url=self.
< version="v1",
< queue=self.queue))
---
> url=self.
> version="v1.1",
> queue=self.queue))
42c41,42
< self.client.
---
> self.headers = helpers.
> self.client.headers = self.headers
43a44
> self.client.
48c49
< self.client.
---
> self.client.
54c55,56
< doc = '[{{"body": "{0}", "ttl": 300}}, {{"body": "{1}", "ttl": 120}}]'
---
> doc = ('{{"messages"
> '{{"body": "{1}", "ttl": 120}}]}}')
69c71
< doc = helpers.
---
> doc = helpers.
86c88
< posted_metadata = doc[0]['body']
---
> posted_metadata = doc['messages'
105c107
< self.assertEqua
---
> self.assertEqua
112c114
< doc = helpers.
---
> doc = helpers.
123,125d124
< self.skipTest('Bug #1273335 - Get set of messages returns wrong hrefs '
< '(happens randomly)')
<
128a128,130
> self.skipTest('Bug #1273335 - Get set of messages returns wrong hrefs '
> '(happens randomly)')
>
130,131c132
< result_body = [result.
< for i in range(len(
---
> result_body = [msg['body'] for msg in result.
134,135c135
< posted_metadata = [doc[i]['body']
< for i in range(message_
---
> posted_metadata = [msg['body'] for msg in doc['messages']]
141a142,162
> def test_message_
> """Insert Single Message into the Queue using the default TTL."""
> doc = helpers.
> default_ttl=True)
>
> result = self.client.
> self.assertEqua
>
> # GET on posted message
> href = result.
> url = self.cfg.zaqar.url + href
>
> result = self.client.
> self.assertEqua
>
> # Compare message metadata
> default_ttl = result.
> self.assertEqua