On the whole we try to avoid filter and map, because comprehensions
are normally much easier to read, and because their behaviour changes
in Python 3. I think the above would clearer as:
architecture = factory.getRandomChoice(
[choice for choice in ARCHITECTURE_CHOICES
if choice[0].endswith('/generic')])
There's assertStartsWith too, if you just want to check that it's
text/plain.
[4]
+ self.assertEqual("Subarchitecture cannot be specified twice",
Sentences end in a full-stop... unless the convention elsewhere in the
codebase to not do that. Very minor point, but it makes a difference
to the overall polish.
Looks good! A few comments, but they're all very minor.
[1]
+ architecture = factory. getRandomChoice ( 0].endswith( '/generic' ), CHOICES) )
+ filter(lambda choice: choice[
+ ARCHITECTURE_
On the whole we try to avoid filter and map, because comprehensions
are normally much easier to read, and because their behaviour changes
in Python 3. I think the above would clearer as:
[choice for choice in ARCHITECTURE_
if choice[
[2]
+ parsed_result = json.loads( response. content) l(httplib. OK, response. status_ code) 'application/ json', response[ 'Content- Type'])
+
+ self.assertEqua
+ self.assertIn(
Don't parse the result until after the response has been checked; it
might fail and then we know less about the failure. How about:
If the response is not OK or the content-type is not JSON, this will
blow up with the mismatch and the response content as detail.
[3]
+ self.assertIn( 'text/plain; charset=utf-8', response[ 'Content- Type'])
There's assertStartsWith too, if you just want to check that it's
text/plain.
[4]
+ self.assertEqua l("Subarchitect ure cannot be specified twice",
Sentences end in a full-stop... unless the convention elsewhere in the
codebase to not do that. Very minor point, but it makes a difference
to the overall polish.
[5]
+ self.assertEqua l(expected_ arch[0] , params_out["arch"]) l(expected_ arch[1] , params_ out["subarch" ])
+ self.assertEqua
Failures would be more informative if this were done in a single
assertion:
[6]
- prefix, node.architecture, release, node.hostname)
+ prefix, node.architectu
+ release, node.hostname)
Because the components are delimited by _, perhaps replace / in the
architecture with - or : instead?