Merge lp:~elachuni/ubuntu-webcatalog/pep8-test into lp:ubuntu-webcatalog

Proposed by Anthony Lenton
Status: Merged
Approved by: Danny Tamez
Approved revision: 61
Merged at revision: 60
Proposed branch: lp:~elachuni/ubuntu-webcatalog/pep8-test
Merge into: lp:ubuntu-webcatalog
Diff against target: 618 lines (+144/-38)
25 files modified
setup.py (+1/-0)
src/webcatalog/admin.py (+1/-0)
src/webcatalog/api/forms.py (+2/-0)
src/webcatalog/api/handlers.py (+8/-4)
src/webcatalog/api/urls.py (+7/-3)
src/webcatalog/auth.py (+12/-7)
src/webcatalog/context_processors.py (+1/-0)
src/webcatalog/department_filters.py (+2/-0)
src/webcatalog/forms.py (+3/-2)
src/webcatalog/management/commands/import_app_install_data.py (+2/-1)
src/webcatalog/management/commands/import_for_purchase_apps.py (+3/-1)
src/webcatalog/models/applications.py (+3/-1)
src/webcatalog/models/oauthtoken.py (+1/-1)
src/webcatalog/schema.py (+1/-1)
src/webcatalog/templatetags/webcatalog.py (+1/-0)
src/webcatalog/tests/__init__.py (+1/-0)
src/webcatalog/tests/test_api.py (+3/-0)
src/webcatalog/tests/test_commands.py (+4/-5)
src/webcatalog/tests/test_models.py (+1/-1)
src/webcatalog/tests/test_pep8.py (+72/-0)
src/webcatalog/tests/test_templatetags.py (+7/-5)
src/webcatalog/tests/test_utilities.py (+4/-3)
src/webcatalog/utilities.py (+1/-1)
src/webcatalog/views.py (+1/-1)
src/webcatalog/wsgi.py (+2/-1)
To merge this branch: bzr merge lp:~elachuni/ubuntu-webcatalog/pep8-test
Reviewer Review Type Date Requested Status
Danny Tamez (community) Approve
Review via email: mp+87792@code.launchpad.net

Commit message

Added a test that checks code against PEP 8, and made it pass.

Description of the change

Overview
========
This branch adds a test that checks our code against PEP8, and makes it pass.

Details
=======
The test itself is copied over from sca/devportal.

To post a comment you must log in.
61. By Anthony Lenton

small doc fix.

Revision history for this message
Danny Tamez (zematynnad) wrote :

I always wondered how many PEP8 changes would have to be made when adding this test :)
Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'setup.py'
--- setup.py 2011-11-17 16:02:20 +0000
+++ setup.py 2012-01-06 18:17:37 +0000
@@ -47,6 +47,7 @@
47 'httplib2',47 'httplib2',
48 'django-pgtools==0.1',48 'django-pgtools==0.1',
49 'rnrclient==1.0',49 'rnrclient==1.0',
50 'pep8',
50 'PIL',51 'PIL',
51 'lazr.restfulclient',52 'lazr.restfulclient',
52 ],53 ],
5354
=== modified file 'src/webcatalog/admin.py'
--- src/webcatalog/admin.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/admin.py 2012-01-06 18:17:37 +0000
@@ -42,6 +42,7 @@
42 list_filter = ('distroseries', 'departments')42 list_filter = ('distroseries', 'departments')
43 exclude = ('for_purchase', 'archive_id')43 exclude = ('for_purchase', 'archive_id')
4444
45
45class MachineAdmin(admin.ModelAdmin):46class MachineAdmin(admin.ModelAdmin):
46 search_fields = ('owner__username', 'hostname', 'uuid')47 search_fields = ('owner__username', 'hostname', 'uuid')
47 list_display = ('hostname', 'uuid', 'owner')48 list_display = ('hostname', 'uuid', 'owner')
4849
=== modified file 'src/webcatalog/api/forms.py'
--- src/webcatalog/api/forms.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/api/forms.py 2012-01-06 18:17:37 +0000
@@ -29,6 +29,7 @@
2929
30from webcatalog.models import Machine30from webcatalog.models import Machine
3131
32
32class MachineCreateUpdateForm(forms.ModelForm):33class MachineCreateUpdateForm(forms.ModelForm):
33 class Meta:34 class Meta:
34 model = Machine35 model = Machine
@@ -37,6 +38,7 @@
37 'logo_checksum',38 'logo_checksum',
38 )39 )
3940
41
40class MachineUpdatePackagesForm(forms.ModelForm):42class MachineUpdatePackagesForm(forms.ModelForm):
41 class Meta:43 class Meta:
42 model = Machine44 model = Machine
4345
=== modified file 'src/webcatalog/api/handlers.py'
--- src/webcatalog/api/handlers.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/api/handlers.py 2012-01-06 18:17:37 +0000
@@ -37,12 +37,14 @@
37from webcatalog.models import Machine37from webcatalog.models import Machine
38from .forms import MachineCreateUpdateForm, MachineUpdatePackagesForm38from .forms import MachineCreateUpdateForm, MachineUpdatePackagesForm
3939
40
40class ServerStatusHandler(BaseHandler):41class ServerStatusHandler(BaseHandler):
41 allowed_methods = ('GET',)42 allowed_methods = ('GET',)
4243
43 def read(self, request):44 def read(self, request):
44 return "ok"45 return "ok"
4546
47
46class ListMachinesHandler(BaseHandler):48class ListMachinesHandler(BaseHandler):
47 allowed_methods = ('GET',)49 allowed_methods = ('GET',)
48 model = Machine50 model = Machine
@@ -52,6 +54,7 @@
52 result = Machine.objects.filter(owner=request.user)54 result = Machine.objects.filter(owner=request.user)
53 return result.defer('package_list')55 return result.defer('package_list')
5456
57
55class MachineHandler(BaseHandler):58class MachineHandler(BaseHandler):
56 allowed_methods = ('GET', 'POST', 'DELETE')59 allowed_methods = ('GET', 'POST', 'DELETE')
57 model = Machine60 model = Machine
@@ -78,7 +81,7 @@
78 for (k, v) in form.errors.items())81 for (k, v) in form.errors.items())
79 result = {'status': 'error', 'errors': errors}82 result = {'status': 'error', 'errors': errors}
80 return result83 return result
81 84
82 def delete(self, request, uuid):85 def delete(self, request, uuid):
83 instances = Machine.objects.filter(owner=request.user, uuid=uuid)86 instances = Machine.objects.filter(owner=request.user, uuid=uuid)
84 if instances.count() > 0:87 if instances.count() > 0:
@@ -86,17 +89,18 @@
86 return HttpResponse(status=204)89 return HttpResponse(status=204)
87 else:90 else:
88 return HttpResponseNotFound('Invalid machine UUID')91 return HttpResponseNotFound('Invalid machine UUID')
89 92
9093
91class PackagesHandler(BaseHandler):94class PackagesHandler(BaseHandler):
92 allowed_methods = ('GET', 'POST',) 95 allowed_methods = ('GET', 'POST',)
96
93 def read(self, request, uuid):97 def read(self, request, uuid):
94 try:98 try:
95 instance = Machine.objects.get(owner=request.user, uuid=uuid)99 instance = Machine.objects.get(owner=request.user, uuid=uuid)
96 return instance.package_list100 return instance.package_list
97 except Machine.DoesNotExist:101 except Machine.DoesNotExist:
98 return HttpResponseNotFound('Invalid machine UUID')102 return HttpResponseNotFound('Invalid machine UUID')
99 103
100 def create(self, request, uuid):104 def create(self, request, uuid):
101 try:105 try:
102 instance = Machine.objects.get(owner=request.user, uuid=uuid)106 instance = Machine.objects.get(owner=request.user, uuid=uuid)
103107
=== modified file 'src/webcatalog/api/urls.py'
--- src/webcatalog/api/urls.py 2011-09-19 19:54:15 +0000
+++ src/webcatalog/api/urls.py 2012-01-06 18:17:37 +0000
@@ -27,6 +27,7 @@
2727
28auth = SSOOAuthAuthentication(realm="Ubuntu Software Center")28auth = SSOOAuthAuthentication(realm="Ubuntu Software Center")
2929
30
30class CSRFExemptResource(Resource):31class CSRFExemptResource(Resource):
31 """A Custom Resource that is csrf exempt"""32 """A Custom Resource that is csrf exempt"""
32 def __init__(self, handler, authentication=None):33 def __init__(self, handler, authentication=None):
@@ -34,9 +35,12 @@
34 self.csrf_exempt = True35 self.csrf_exempt = True
3536
36server_status_resource = Resource(handler=ServerStatusHandler)37server_status_resource = Resource(handler=ServerStatusHandler)
37list_machines_resource = Resource(handler=ListMachinesHandler, authentication=auth)38list_machines_resource = Resource(handler=ListMachinesHandler,
38machine_resource = CSRFExemptResource(handler=MachineHandler, authentication=auth)39 authentication=auth)
39packages_resource = CSRFExemptResource(handler=PackagesHandler, authentication=auth)40machine_resource = CSRFExemptResource(handler=MachineHandler,
41 authentication=auth)
42packages_resource = CSRFExemptResource(handler=PackagesHandler,
43 authentication=auth)
4044
41urlpatterns = patterns('',45urlpatterns = patterns('',
42 # get status of the service (usually just "ok", might be "read-only")46 # get status of the service (usually just "ok", might be "read-only")
4347
=== modified file 'src/webcatalog/auth.py'
--- src/webcatalog/auth.py 2011-09-19 20:01:32 +0000
+++ src/webcatalog/auth.py 2012-01-06 18:17:37 +0000
@@ -39,8 +39,9 @@
39 full_claimed_id,39 full_claimed_id,
40)40)
4141
42TOKEN_CACHE_EXPIRY = timedelta(hours=42TOKEN_CACHE_EXPIRY = timedelta(hours=getattr(settings,
43 getattr(settings, 'TOKEN_CACHE_EXPIRY_HOURS', 4))43 'TOKEN_CACHE_EXPIRY_HOURS', 4))
44
4445
45class SSOOAuthAuthentication(OAuthAuthentication):46class SSOOAuthAuthentication(OAuthAuthentication):
46 """ This class is a Piston Authentication class.47 """ This class is a Piston Authentication class.
@@ -65,7 +66,7 @@
65 before the oauth mechanism asks us for them66 before the oauth mechanism asks us for them
66 """67 """
67 http_auth = request.META.get('HTTP_AUTHORIZATION', '')68 http_auth = request.META.get('HTTP_AUTHORIZATION', '')
68 headers = {'Authorization' : http_auth}69 headers = {'Authorization': http_auth}
69 orequest = oauth.OAuthRequest.from_request(70 orequest = oauth.OAuthRequest.from_request(
70 request.method, request.build_absolute_uri(), headers=headers,71 request.method, request.build_absolute_uri(), headers=headers,
71 query_string=request.META['QUERY_STRING'])72 query_string=request.META['QUERY_STRING'])
@@ -98,7 +99,8 @@
98 if len(tokens) == 0 or (tokens[0].updated_at <99 if len(tokens) == 0 or (tokens[0].updated_at <
99 datetime.now() - TOKEN_CACHE_EXPIRY):100 datetime.now() - TOKEN_CACHE_EXPIRY):
100 pieces = web_services.get_data_for_account(token=oauthtoken,101 pieces = web_services.get_data_for_account(token=oauthtoken,
101 openid_identifier=consumer_key, signature=request.get_parameter('oauth_signature'))102 openid_identifier=consumer_key,
103 signature=request.get_parameter('oauth_signature'))
102 if not pieces:104 if not pieces:
103 return105 return
104 Consumer.objects.filter(key=consumer_key).exclude(106 Consumer.objects.filter(key=consumer_key).exclude(
@@ -137,12 +139,13 @@
137 raise OAuthError('initialize_server_request returned None')139 raise OAuthError('initialize_server_request returned None')
138 return oauth_server.verify_request(oauth_request)140 return oauth_server.verify_request(oauth_request)
139141
142
140def initialize_server_request(request):143def initialize_server_request(request):
141 """144 """
142 Shortcut for initialization.145 Shortcut for initialization.
143 """146 """
144 headers = {147 headers = {
145 'Authorization' : request.META.get('HTTP_AUTHORIZATION', '')148 'Authorization': request.META.get('HTTP_AUTHORIZATION', '')
146 }149 }
147 oauth_request = oauth.OAuthRequest.from_request(150 oauth_request = oauth.OAuthRequest.from_request(
148 request.method, request.build_absolute_uri(), headers=headers,151 request.method, request.build_absolute_uri(), headers=headers,
@@ -150,8 +153,10 @@
150153
151 if oauth_request:154 if oauth_request:
152 oauth_server = oauth.OAuthServer(oauth_datastore(oauth_request))155 oauth_server = oauth.OAuthServer(oauth_datastore(oauth_request))
153 oauth_server.add_signature_method(oauth.OAuthSignatureMethod_PLAINTEXT())156 oauth_server.add_signature_method(
154 oauth_server.add_signature_method(oauth.OAuthSignatureMethod_HMAC_SHA1())157 oauth.OAuthSignatureMethod_PLAINTEXT())
158 oauth_server.add_signature_method(
159 oauth.OAuthSignatureMethod_HMAC_SHA1())
155 else:160 else:
156 oauth_server = None161 oauth_server = None
157162
158163
=== modified file 'src/webcatalog/context_processors.py'
--- src/webcatalog/context_processors.py 2012-01-06 14:24:49 +0000
+++ src/webcatalog/context_processors.py 2012-01-06 18:17:37 +0000
@@ -19,6 +19,7 @@
1919
20from django.conf import settings20from django.conf import settings
2121
22
22def google_analytics_id(request):23def google_analytics_id(request):
23 """Adds the google analytics id to the context if it's present."""24 """Adds the google analytics id to the context if it's present."""
24 return {25 return {
2526
=== modified file 'src/webcatalog/department_filters.py'
--- src/webcatalog/department_filters.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/department_filters.py 2012-01-06 18:17:37 +0000
@@ -38,12 +38,14 @@
38 return bool(app.categories_set.intersection(categories_set))38 return bool(app.categories_set.intersection(categories_set))
39 return filter_func39 return filter_func
4040
41
41def package_name_filter(name_regex):42def package_name_filter(name_regex):
42 """Returns a filter func that checks if an app's name matches a regex"""43 """Returns a filter func that checks if an app's name matches a regex"""
43 def filter_func(app):44 def filter_func(app):
44 return re.match(name_regex, app.package_name) is not None45 return re.match(name_regex, app.package_name) is not None
45 return filter_func46 return filter_func
4647
48
47def section_filter(sections):49def section_filter(sections):
48 """Returns a filter that checks if an app is in certain sections."""50 """Returns a filter that checks if an app is in certain sections."""
49 def filter_func(app):51 def filter_func(app):
5052
=== modified file 'src/webcatalog/forms.py'
--- src/webcatalog/forms.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/forms.py 2012-01-06 18:17:37 +0000
@@ -53,7 +53,7 @@
5353
54 class Meta:54 class Meta:
55 model = Application55 model = Application
56 exclude = ('distroseries','for_purchase', 'archive_id', 'price')56 exclude = ('distroseries', 'for_purchase', 'archive_id', 'price')
5757
58 @classmethod58 @classmethod
59 def get_form_from_desktop_data(cls, str_data, distroseries):59 def get_form_from_desktop_data(cls, str_data, distroseries):
@@ -61,7 +61,7 @@
61 parser.readfp(StringIO(str_data))61 parser.readfp(StringIO(str_data))
62 data = dict(parser.items('Desktop Entry'))62 data = dict(parser.items('Desktop Entry'))
63 for desktop_key, app_key in desktop_field_mappings.items():63 for desktop_key, app_key in desktop_field_mappings.items():
64 if data.has_key(desktop_key):64 if desktop_key in data:
65 data[app_key] = data[desktop_key]65 data[app_key] = data[desktop_key]
66 del(data[desktop_key])66 del(data[desktop_key])
6767
@@ -86,6 +86,7 @@
8686
87 return cleaned_data87 return cleaned_data
8888
89
89class ForPurchaseApplicationForm(forms.ModelForm):90class ForPurchaseApplicationForm(forms.ModelForm):
90 class Meta:91 class Meta:
91 model = Application92 model = Application
9293
=== modified file 'src/webcatalog/management/commands/import_app_install_data.py'
--- src/webcatalog/management/commands/import_app_install_data.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/management/commands/import_app_install_data.py 2012-01-06 18:17:37 +0000
@@ -135,7 +135,8 @@
135135
136 # Extract and parse the deb archive.136 # Extract and parse the deb archive.
137 deb_file = DebFile(deb_location)137 deb_file = DebFile(deb_location)
138 self.output("Processing application data to update database...\n", 1)138 self.output("Processing application data to update database...\n",
139 1)
139 deb_file.data.extractall(data_dir)140 deb_file.data.extractall(data_dir)
140 matcher = data_dir + '/usr/share/app-install/desktop/*.desktop'141 matcher = data_dir + '/usr/share/app-install/desktop/*.desktop'
141 icon_dir = data_dir + '/usr/share/app-install/icons/'142 icon_dir = data_dir + '/usr/share/app-install/icons/'
142143
=== modified file 'src/webcatalog/management/commands/import_for_purchase_apps.py'
--- src/webcatalog/management/commands/import_for_purchase_apps.py 2011-09-15 08:58:19 +0000
+++ src/webcatalog/management/commands/import_for_purchase_apps.py 2012-01-06 18:17:37 +0000
@@ -15,7 +15,9 @@
15# You should have received a copy of the GNU Affero General Public License15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18"""Management command to import for purchase applications from Software Center."""18"""Management command to import for purchase applications from Software
19 Center.
20"""
1921
20from __future__ import (22from __future__ import (
21 absolute_import,23 absolute_import,
2224
=== modified file 'src/webcatalog/models/applications.py'
--- src/webcatalog/models/applications.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/models/applications.py 2012-01-06 18:17:37 +0000
@@ -175,7 +175,7 @@
175 if distro is not None:175 if distro is not None:
176 args = [distro]176 args = [distro]
177 args.append(self.id)177 args.append(self.id)
178 url =reverse('wc-department', args=args)178 url = reverse('wc-department', args=args)
179 crumbs.append({'name': self.name, 'url': url})179 crumbs.append({'name': self.name, 'url': url})
180 return crumbs180 return crumbs
181181
@@ -186,6 +186,7 @@
186class ReviewStatsImport(models.Model):186class ReviewStatsImport(models.Model):
187 distroseries = models.ForeignKey(DistroSeries, unique=True)187 distroseries = models.ForeignKey(DistroSeries, unique=True)
188 last_import = models.DateTimeField(default=datetime.utcnow)188 last_import = models.DateTimeField(default=datetime.utcnow)
189
189 class Meta:190 class Meta:
190 app_label = 'webcatalog'191 app_label = 'webcatalog'
191192
@@ -197,6 +198,7 @@
197 packages_checksum = models.CharField(max_length=56)198 packages_checksum = models.CharField(max_length=56)
198 package_list = models.TextField()199 package_list = models.TextField()
199 logo_checksum = models.CharField(max_length=56, blank=True)200 logo_checksum = models.CharField(max_length=56, blank=True)
201
200 class Meta:202 class Meta:
201 app_label = 'webcatalog'203 app_label = 'webcatalog'
202 unique_together = ('owner', 'uuid')204 unique_together = ('owner', 'uuid')
203205
=== modified file 'src/webcatalog/models/oauthtoken.py'
--- src/webcatalog/models/oauthtoken.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/models/oauthtoken.py 2012-01-06 18:17:37 +0000
@@ -151,6 +151,7 @@
151 class Meta:151 class Meta:
152 app_label = 'webcatalog'152 app_label = 'webcatalog'
153153
154
154class DataStore(OAuthDataStore):155class DataStore(OAuthDataStore):
155156
156 def lookup_token(self, token_type, token_field):157 def lookup_token(self, token_type, token_field):
@@ -186,7 +187,6 @@
186 if consumer is not None:187 if consumer is not None:
187 return consumer.oauth_consumer()188 return consumer.oauth_consumer()
188189
189
190 def lookup_nonce(self, consumer, token, nonce):190 def lookup_nonce(self, consumer, token, nonce):
191 """191 """
192 :param consumer: OAuthConsumer object192 :param consumer: OAuthConsumer object
193193
=== modified file 'src/webcatalog/schema.py'
--- src/webcatalog/schema.py 2012-01-06 14:24:49 +0000
+++ src/webcatalog/schema.py 2012-01-06 18:17:37 +0000
@@ -76,7 +76,7 @@
76 rnr = ConfigSection()76 rnr = ConfigSection()
77 rnr.rnr_service_root = StringConfigOption(77 rnr.rnr_service_root = StringConfigOption(
78 default="http://reviews.ubuntu.com/reviews/api/1.0")78 default="http://reviews.ubuntu.com/reviews/api/1.0")
79 rnr.reviews_cache_timeout = IntConfigOption(default=60*15)79 rnr.reviews_cache_timeout = IntConfigOption(default=60 * 15)
8080
81 sso_api = ConfigSection()81 sso_api = ConfigSection()
82 sso_api.sso_api_service_root = StringConfigOption()82 sso_api.sso_api_service_root = StringConfigOption()
8383
=== modified file 'src/webcatalog/templatetags/webcatalog.py'
--- src/webcatalog/templatetags/webcatalog.py 2011-09-15 10:53:40 +0000
+++ src/webcatalog/templatetags/webcatalog.py 2012-01-06 18:17:37 +0000
@@ -155,6 +155,7 @@
155 old_indent_level = indent_level155 old_indent_level = indent_level
156 return norm_description.strip()156 return norm_description.strip()
157157
158
158@register.filter159@register.filter
159def htmlize_package_description(desc):160def htmlize_package_description(desc):
160 html = ""161 html = ""
161162
=== modified file 'src/webcatalog/tests/__init__.py'
--- src/webcatalog/tests/__init__.py 2012-01-06 14:24:49 +0000
+++ src/webcatalog/tests/__init__.py 2012-01-06 18:17:37 +0000
@@ -23,6 +23,7 @@
23from .test_forms import *23from .test_forms import *
24from .test_handlers import *24from .test_handlers import *
25from .test_models import *25from .test_models import *
26from .test_pep8 import *
26from .test_templatetags import *27from .test_templatetags import *
27from .test_utilities import *28from .test_utilities import *
28from .test_views import *29from .test_views import *
2930
=== modified file 'src/webcatalog/tests/test_api.py'
--- src/webcatalog/tests/test_api.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/tests/test_api.py 2012-01-06 18:17:37 +0000
@@ -43,11 +43,13 @@
43from .factory import TestCaseWithFactory43from .factory import TestCaseWithFactory
44from webcatalog.models import Machine44from webcatalog.models import Machine
4545
46
46class ServerStatusTestCase(TestCase):47class ServerStatusTestCase(TestCase):
47 def test_server_status(self):48 def test_server_status(self):
48 response = self.client.get('/cat/api/1.0/server-status/')49 response = self.client.get('/cat/api/1.0/server-status/')
49 self.assertEqual(response.content, '"ok"')50 self.assertEqual(response.content, '"ok"')
5051
52
51class AuthenticatedAPITestCase(TestCaseWithFactory):53class AuthenticatedAPITestCase(TestCaseWithFactory):
52 def auth_header_for_user(self, url, user=None, realm='OAuth'):54 def auth_header_for_user(self, url, user=None, realm='OAuth'):
53 token, consumer = self.factory.make_oauth_token_and_consumer(user=user)55 token, consumer = self.factory.make_oauth_token_and_consumer(user=user)
@@ -63,6 +65,7 @@
6365
64class ListMachinesTestCase(AuthenticatedAPITestCase):66class ListMachinesTestCase(AuthenticatedAPITestCase):
65 url = '/cat/api/1.0/list-machines/'67 url = '/cat/api/1.0/list-machines/'
68
66 def test_no_auth_returns_401(self):69 def test_no_auth_returns_401(self):
67 response = self.client.get(self.url)70 response = self.client.get(self.url)
68 self.assertEqual(401, response.status_code)71 self.assertEqual(401, response.status_code)
6972
=== modified file 'src/webcatalog/tests/test_commands.py'
--- src/webcatalog/tests/test_commands.py 2011-09-15 10:53:40 +0000
+++ src/webcatalog/tests/test_commands.py 2012-01-06 18:17:37 +0000
@@ -89,9 +89,9 @@
89 mock_cache = MagicMock()89 mock_cache = MagicMock()
90 mock_apt_firefox = self.make_mock_apt_package('firefox',90 mock_apt_firefox = self.make_mock_apt_package('firefox',
91 description="Firefox description")91 description="Firefox description")
92 mock_apt_scribus=self.make_mock_apt_package('scribus',92 mock_apt_scribus = self.make_mock_apt_package('scribus',
93 description="Scribus description")93 description="Scribus description")
94 mock_other_app=self.make_mock_apt_package('otherapp',94 mock_other_app = self.make_mock_apt_package('otherapp',
95 description="Otherapp description",95 description="Otherapp description",
96 summary="Otherapp the Internet\nA tagline for Otherapp")96 summary="Otherapp the Internet\nA tagline for Otherapp")
97 mock_app_install_data = self.make_mock_apt_package('app-install-data',97 mock_app_install_data = self.make_mock_apt_package('app-install-data',
@@ -169,7 +169,8 @@
169 with patch(get_uri_fn) as mock_get_uri:169 with patch(get_uri_fn) as mock_get_uri:
170 mock_get_uri.return_value = 'http://example.com/my.deb'170 mock_get_uri.return_value = 'http://example.com/my.deb'
171 with patch('urllib.urlretrieve') as mock_urlretrieve:171 with patch('urllib.urlretrieve') as mock_urlretrieve:
172 ImportAppInstallCommand().get_latest_app_data_for_series('natty', tmp_dir)172 ImportAppInstallCommand().get_latest_app_data_for_series(
173 'natty', tmp_dir)
173 shutil.rmtree(tmp_dir)174 shutil.rmtree(tmp_dir)
174175
175 mock_urlretrieve.assert_called_with(176 mock_urlretrieve.assert_called_with(
@@ -540,5 +541,3 @@
540541
541 # update_apps_with_stats returns None on success:542 # update_apps_with_stats returns None on success:
542 self.assertIsNone(command.update_apps_with_stats(natty, stats))543 self.assertIsNone(command.update_apps_with_stats(natty, stats))
543
544
545544
=== modified file 'src/webcatalog/tests/test_models.py'
--- src/webcatalog/tests/test_models.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/tests/test_models.py 2012-01-06 18:17:37 +0000
@@ -102,7 +102,7 @@
102 def test_normalized_name(self):102 def test_normalized_name(self):
103 cases = {103 cases = {
104 'Foo': 'Foo',104 'Foo': 'Foo',
105 'Foo & Bar': 'FooBar',105 'Foo & Bar': 'FooBar',
106 ' Foo, Bar ': 'FooBar',106 ' Foo, Bar ': 'FooBar',
107 ' && , ': '',107 ' && , ': '',
108 '': ''108 '': ''
109109
=== added file 'src/webcatalog/tests/test_pep8.py'
--- src/webcatalog/tests/test_pep8.py 1970-01-01 00:00:00 +0000
+++ src/webcatalog/tests/test_pep8.py 2012-01-06 18:17:37 +0000
@@ -0,0 +1,72 @@
1# -*- coding: utf-8 -*-
2# This file is part of the Apps Directory
3# Copyright (C) 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Affero General Public License as
7# published by the Free Software Foundation, either version 3 of the
8# License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18"""Apps Directory pep-8 compliance tests."""
19
20from __future__ import absolute_import
21
22__metaclass__ = type
23__all__ = [
24 'WebCatalogPep8TestCase',
25 ]
26
27import os
28import pep8
29from collections import defaultdict
30from unittest import TestCase
31
32import webcatalog
33
34
35class PackagePep8TestCase(TestCase):
36 maxDiff = None
37 packages = []
38 exclude = ['migrations']
39
40 def message(self, text):
41 self.errors.append(text)
42
43 def setUp(self):
44 self.errors = []
45
46 class Options(object):
47 exclude = self.exclude
48 filename = ['*.py']
49 testsuite = ''
50 doctest = ''
51 counters = defaultdict(int)
52 messages = {}
53 verbose = 0
54 quiet = 0
55 repeat = True
56 show_source = False
57 show_pep8 = False
58 select = []
59 ignore = []
60 pep8.options = Options()
61 pep8.message = self.message
62 Options.physical_checks = pep8.find_checks('physical_line')
63 Options.logical_checks = pep8.find_checks('logical_line')
64
65 def test_all_code(self):
66 for package in self.packages:
67 pep8.input_dir(os.path.dirname(package.__file__))
68 self.assertEqual([], self.errors)
69
70
71class WebCatalogPep8TestCase(PackagePep8TestCase):
72 packages = [webcatalog]
073
=== modified file 'src/webcatalog/tests/test_templatetags.py'
--- src/webcatalog/tests/test_templatetags.py 2011-09-15 10:53:40 +0000
+++ src/webcatalog/tests/test_templatetags.py 2012-01-06 18:17:37 +0000
@@ -182,7 +182,8 @@
182* Lha archives (.lzh)182* Lha archives (.lzh)
183* Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),183* Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),
184 compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)184 compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)
185File-roller doesn't perform archive operations by itself, but relies on standard tools for this.185File-roller doesn't perform archive operations by itself, but relies on \
186standard tools for this.
186"""187"""
187188
188#drgeo189#drgeo
@@ -240,6 +241,7 @@
240 * Extensible with plugins241 * Extensible with plugins
241"""242"""
242243
244
243class HtmlizePackageDescriptionTestCase(unittest.TestCase):245class HtmlizePackageDescriptionTestCase(unittest.TestCase):
244 def test_htmlize(self):246 def test_htmlize(self):
245 for descr in [d1, d2, d3]:247 for descr in [d1, d2, d3]:
@@ -275,13 +277,13 @@
275class VisiblePageRangeTestCase(unittest.TestCase):277class VisiblePageRangeTestCase(unittest.TestCase):
276 def test_visible_page_range(self):278 def test_visible_page_range(self):
277 cases = [279 cases = [
278 ( 2, 1, [1, 2]),280 (2, 1, [1, 2]),
279 (20, 1, range(1, 11)),281 (20, 1, range(1, 11)),
280 ( 3, 2, [1, 2, 3]),282 (3, 2, [1, 2, 3]),
281 (20, 2, range(1, 11)),283 (20, 2, range(1, 11)),
282 ( 4, 4, [1, 2, 3, 4]),284 (4, 4, [1, 2, 3, 4]),
283 (20, 8, range(3, 13)),285 (20, 8, range(3, 13)),
284 ( 8, 8, range(3, 9)),286 (8, 8, range(3, 9)),
285 (20, 18, range(13, 21)),287 (20, 18, range(13, 21)),
286 (400, 400, range(395, 401)),288 (400, 400, range(395, 401)),
287 ]289 ]
288290
=== modified file 'src/webcatalog/tests/test_utilities.py'
--- src/webcatalog/tests/test_utilities.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/tests/test_utilities.py 2012-01-06 18:17:37 +0000
@@ -22,12 +22,13 @@
22from webcatalog.tests.factory import TestCaseWithFactory22from webcatalog.tests.factory import TestCaseWithFactory
23from webcatalog.utilities import create_png_from_file23from webcatalog.utilities import create_png_from_file
2424
25
25class CreatePNGFromFileTestCase(TestCaseWithFactory):26class CreatePNGFromFileTestCase(TestCaseWithFactory):
26 def test_file_conversion(self):27 def test_file_conversion(self):
27 filenames = [28 filenames = [
28 self.factory.get_test_path('firefox.xpm'), # Regular xpm29 self.factory.get_test_path('firefox.xpm'), # Regular xpm
29 self.factory.get_test_path('mini-gsmc.xpm'), # named colors30 self.factory.get_test_path('mini-gsmc.xpm'), # named colors
30 self.factory.get_test_path('access.svg'), # SVG file31 self.factory.get_test_path('access.svg'), # SVG file
31 ]32 ]
32 pngpath = 'test_file_DELETEME.png'33 pngpath = 'test_file_DELETEME.png'
33 for f in filenames:34 for f in filenames:
3435
=== modified file 'src/webcatalog/utilities.py'
--- src/webcatalog/utilities.py 2011-09-15 13:40:53 +0000
+++ src/webcatalog/utilities.py 2012-01-06 18:17:37 +0000
@@ -102,7 +102,7 @@
102 if cached_reviews is not None:102 if cached_reviews is not None:
103 return cached_reviews103 return cached_reviews
104104
105 fresh_reviews = self.rnr_api.get_reviews(packagename=package_name, 105 fresh_reviews = self.rnr_api.get_reviews(packagename=package_name,
106 distroseries=distroseries, page=page)106 distroseries=distroseries, page=page)
107 cache.set(key, fresh_reviews, settings.REVIEWS_CACHE_TIMEOUT)107 cache.set(key, fresh_reviews, settings.REVIEWS_CACHE_TIMEOUT)
108 return fresh_reviews108 return fresh_reviews
109109
=== modified file 'src/webcatalog/views.py'
--- src/webcatalog/views.py 2011-09-16 09:43:11 +0000
+++ src/webcatalog/views.py 2012-01-06 18:17:37 +0000
@@ -182,7 +182,7 @@
182 app = get_object_or_404(Application, package_name=package_name,182 app = get_object_or_404(Application, package_name=package_name,
183 distroseries__code_name=distro)183 distroseries__code_name=distro)
184 # XXX michaeln 2011-09-15 bug=851662 Better review language options.184 # XXX michaeln 2011-09-15 bug=851662 Better review language options.
185 reviews = WebServices().get_reviews_for_package(package_name, 185 reviews = WebServices().get_reviews_for_package(package_name,
186 distroseries=distro, page=page)186 distroseries=distro, page=page)
187187
188 context = dict(application=app, reviews=reviews)188 context = dict(application=app, reviews=reviews)
189189
=== modified file 'src/webcatalog/wsgi.py'
--- src/webcatalog/wsgi.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/wsgi.py 2012-01-06 18:17:37 +0000
@@ -25,8 +25,9 @@
25from django.core.handlers.wsgi import WSGIHandler25from django.core.handlers.wsgi import WSGIHandler
26from django.conf import settings26from django.conf import settings
2727
28
28def make_app():29def make_app():
29 """Encapsulate our webcatalog handler in an OOPS app for error reporting."""30 """Encapsulate our webcatalog handler in an OOPS app."""
30 default_id = ''.join(x for x in platform.node() if x.isalpha())31 default_id = ''.join(x for x in platform.node() if x.isalpha())
31 appserver_id = getattr(settings, 'APPSERVER_ID', default_id)32 appserver_id = getattr(settings, 'APPSERVER_ID', default_id)
32 logging.config.fileConfig(settings.WEBAPP_LOGGING_CONFIG)33 logging.config.fileConfig(settings.WEBAPP_LOGGING_CONFIG)

Subscribers

People subscribed via source and target branches