This is half a review. I have to go out, and I'll finish it later.
As for splitting it up, for one you could have added an empty add_ucsm()
function to NodeGroup, building the API calls around it, and writing
tests in which you mock the behaviour of add_ucsm().
[1]
Hope-quoting, as Julian has mentioned.
[2]
+ def add_ucsm(self, url, username, password):
This isn't a great name for this method. However, I see that it's
consistent with what's gone before.
This is half a review. I have to go out, and I'll finish it later.
As for splitting it up, for one you could have added an empty add_ucsm()
function to NodeGroup, building the API calls around it, and writing
tests in which you mock the behaviour of add_ucsm().
[1]
Hope-quoting, as Julian has mentioned.
[2]
+ def add_ucsm(self, url, username, password):
This isn't a great name for this method. However, I see that it's
consistent with what's gone before.
[3]
+ children = map(Element, children_tags) data('foo' , fields, children)
+ request_data = make_request_
Bear in mind that map() is lazy in Python 3. Will make_request_data()
deal with that? If not, make it explicit with a list comprehension.
[4]
+ self.assertEqua l(set(children_ tags), set([e.tag for e in root[:]]))
The list-comprehension is not needed:
Not sure the slice is either?
Having said that, assertItemsEqual() is useful here:
[5]
+ self.assertRais es(UCSM_ XML_API_ Error, lambda: parse_response( xml))
assertRaises() allows arguments, so you can write this as:
[6]
+ def make_test_api(self, url='http:// url', user='u', password='p',
+ cookie='foo', mock_call=True):
+
+ api = make_test_api(url, user, password, cookie)
+
+ if mock_call:
+ mock = self.patch(api, '_call')
+ else:
+ mock = None
+
+ return api, mock
Boolean arguments are a bit smelly, as is returning irrelevant
things. Can you split this into two methods?
def make_test_api( url', user='u', password='p', cookie='foo'):
self, url='http://
return make_test_api(url, user, password, cookie)
def make_test_api( url', user='u', password='p', cookie='foo'):
self, url='http://
api = make_test_api(url, user, password, cookie)
return api, self.patch(api, '_call')
To be continued...