| Conditions | 1 |
| Total Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # coding: utf8 |
||
| 91 | @freeze_time('2014-10-14 08:28:05') |
||
| 92 | @temporary_media_root(MEDIA_URL='http://cache.pack.google.com/edgedl/chrome/install/782.112/') |
||
| 93 | def test_sparkle_critical(self): |
||
| 94 | app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome') |
||
| 95 | channel = ChannelFactory.create(name='stable') |
||
| 96 | first_version = SparkleVersionFactory.create( |
||
| 97 | app=app, |
||
| 98 | channel=channel, |
||
| 99 | version='782.110', |
||
| 100 | short_version='13.0.782.110', |
||
| 101 | file=SimpleUploadedFile('./chrome1.dmg', b'_' * 23963192), |
||
| 102 | file_size=23963192) |
||
| 103 | first_version.save() |
||
| 104 | |||
| 105 | first_crit_version = SparkleVersionFactory.create( |
||
| 106 | app=app, |
||
| 107 | channel=channel, |
||
| 108 | version='782.111', |
||
| 109 | short_version='13.0.782.111', |
||
| 110 | is_critical=True, |
||
| 111 | file=SimpleUploadedFile('./chrome2.dmg', b'_' * 23963192), |
||
| 112 | file_size=23963192) |
||
| 113 | first_crit_version.save() |
||
| 114 | |||
| 115 | last_version = SparkleVersionFactory.create( |
||
| 116 | app=app, |
||
| 117 | channel=channel, |
||
| 118 | version='782.112', |
||
| 119 | short_version='13.0.782.112', |
||
| 120 | file=SimpleUploadedFile('./chrome3.dmg', b'_' * 23963192), |
||
| 121 | file_size=23963192) |
||
| 122 | last_version.save() |
||
| 123 | |||
| 124 | second_crit_version = SparkleVersionFactory.create( |
||
| 125 | app=app, |
||
| 126 | channel=channel, |
||
| 127 | version='782.113', |
||
| 128 | short_version='13.0.782.113', |
||
| 129 | is_critical=True, |
||
| 130 | file=SimpleUploadedFile('./chrome4.dmg', b'_' * 23963192), |
||
| 131 | file_size=23963192) |
||
| 132 | second_crit_version.save() |
||
| 133 | |||
| 134 | response = self.client.get("%s?appVersionShort=13.0.782.110" % reverse('sparkle_appcast', args=(app.name, channel.name)), |
||
| 135 | HTTP_HOST='example.com') |
||
| 136 | |||
| 137 | self.assertEqual(response.status_code, 200) |
||
| 138 | |||
| 139 | self.assertXmlDocument(response.content) |
||
| 140 | self.assertXmlEquivalentOutputs(response.content, |
||
| 141 | fixtures.first_crit_response_sparkle) |
||
| 142 | |||
| 143 | response = self.client.get("%s?appVersionShort=13.0.782.111" % reverse('sparkle_appcast', args=(app.name, channel.name)), |
||
| 144 | HTTP_HOST='example.com') |
||
| 145 | |||
| 146 | self.assertEqual(response.status_code, 200) |
||
| 147 | |||
| 148 | self.assertXmlDocument(response.content) |
||
| 149 | self.assertXmlEquivalentOutputs(response.content, |
||
| 150 | fixtures.second_crit_response_sparkle) |
||
| 151 | |||
| 195 |