| Conditions | 1 |
| Total Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 88 | @freeze_time('2014-10-14 08:28:05') |
||
| 89 | @temporary_media_root(MEDIA_URL='http://cache.pack.google.com/edgedl/chrome/install/782.112/') |
||
| 90 | def test_sparkle_critical(self): |
||
| 91 | app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome') |
||
| 92 | channel = ChannelFactory.create(name='stable') |
||
| 93 | first_version = SparkleVersionFactory.create( |
||
| 94 | app=app, |
||
| 95 | channel=channel, |
||
| 96 | version='782.110', |
||
| 97 | short_version='13.0.782.110', |
||
| 98 | file=SimpleUploadedFile('./chrome1.dmg', b'_' * 23963192), |
||
| 99 | file_size=23963192) |
||
| 100 | first_version.save() |
||
| 101 | |||
| 102 | first_crit_version = SparkleVersionFactory.create( |
||
| 103 | app=app, |
||
| 104 | channel=channel, |
||
| 105 | version='782.111', |
||
| 106 | short_version='13.0.782.111', |
||
| 107 | is_critical=True, |
||
| 108 | file=SimpleUploadedFile('./chrome2.dmg', b'_' * 23963192), |
||
| 109 | file_size=23963192) |
||
| 110 | first_crit_version.save() |
||
| 111 | |||
| 112 | last_version = SparkleVersionFactory.create( |
||
| 113 | app=app, |
||
| 114 | channel=channel, |
||
| 115 | version='782.112', |
||
| 116 | short_version='13.0.782.112', |
||
| 117 | file=SimpleUploadedFile('./chrome3.dmg', b'_' * 23963192), |
||
| 118 | file_size=23963192) |
||
| 119 | last_version.save() |
||
| 120 | |||
| 121 | last_version = SparkleVersionFactory.create( |
||
| 122 | app=app, |
||
| 123 | channel=channel, |
||
| 124 | version='782.113', |
||
| 125 | short_version='13.0.782.113', |
||
| 126 | is_critical=True, |
||
| 127 | file=SimpleUploadedFile('./chrome4.dmg', b'_' * 23963192), |
||
| 128 | file_size=23963192) |
||
| 129 | first_version.save() |
||
| 130 | |||
| 131 | response = self.client.get("%s?appVersionShort=13.0.782.110" % reverse('sparkle_appcast', args=(app.name, channel.name)), |
||
| 132 | HTTP_HOST='example.com') |
||
| 133 | |||
| 134 | self.assertEqual(response.status_code, 200) |
||
| 135 | |||
| 136 | self.assertXmlDocument(response.content) |
||
| 137 | self.assertXmlEquivalentOutputs(response.content, |
||
| 138 | fixtures.first_crit_response_sparkle) |
||
| 139 | |||
| 140 | response = self.client.get("%s?appVersionShort=13.0.782.111" % reverse('sparkle_appcast', args=(app.name, channel.name)), |
||
| 141 | HTTP_HOST='example.com') |
||
| 142 | |||
| 143 | self.assertEqual(response.status_code, 200) |
||
| 144 | |||
| 145 | self.assertXmlDocument(response.content) |
||
| 146 | self.assertXmlEquivalentOutputs(response.content, |
||
| 147 | fixtures.second_crit_response_sparkle) |
||
| 148 |