Skip to content

Commit

Permalink
[#1117] PEP8 fixes
Browse files Browse the repository at this point in the history
Make the PEP8 tests happy
  • Loading branch information
Sean Hammond committed Aug 1, 2013
1 parent 1267791 commit 3a0bb76
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
12 changes: 8 additions & 4 deletions ckan/new_tests/factories.py
Expand Up @@ -41,6 +41,12 @@
import ckan.new_tests.helpers as helpers


def generate_email(user):
'''Return an email address for the given User factory stub object.'''

return '{0}@ckan.org'.format(user.name).lower()


class User(factory.Factory):
'''A factory class for creating CKAN users.'''

Expand All @@ -54,13 +60,11 @@ class User(factory.Factory):
about = 'Just another test user.'

# Generate a different user name param for each user that gets created.
name = factory.Sequence(
lambda n: 'test_user_{n}'.format(n=n))
name = factory.Sequence(lambda n: 'test_user_{n}'.format(n=n))

# Compute the email param for each user based on the values of the other
# params above.
email = factory.LazyAttribute(
lambda a: '{0}@ckan.org'.format(a.name).lower())
email = factory.LazyAttribute(generate_email)

# I'm not sure how to support factory_boy's .build() feature in CKAN,
# so I've disabled it here.
Expand Down
14 changes: 8 additions & 6 deletions ckan/new_tests/lib/navl/test_validators.py
Expand Up @@ -45,18 +45,20 @@ def test_ignore_missing_with_value_missing(self):
context={})

assert key not in data, ('When given a value of {value} '
'ignore_missing() should remove the item from the data '
'dict'.format(value=value))
'ignore_missing() should remove the item '
'from the data dict'.format(value=value))

if key in original_data:
del original_data[key]
assert data == original_data, ('When given a value of {value} '
'ignore_missing() should not modify other items in the '
'data dict'.format(value=value))
'ignore_missing() should not '
'modify other items in the '
'data dict'.format(value=value))

assert errors == original_errors, ('When given a value of {value} '
'ignore_missing should not modify the errors dict'.format(
value=value))
'ignore_missing should not '
'modify the errors '
'dict'.format(value=value))

def test_ignore_missing_with_a_value(self):
'''If data[key] is neither None or missing, ignore_missing() should do
Expand Down
2 changes: 1 addition & 1 deletion ckan/new_tests/logic/action/test_update.py
Expand Up @@ -96,7 +96,7 @@ def test_user_update_with_invalid_name(self):

def test_user_update_to_name_that_already_exists(self):
fred = factories.User(name='fred')
bob = factories.User(name='bob')
bob = factories.User(name='bob')

# Try to update fred and change his user name to bob, which is already
# bob's user name
Expand Down
2 changes: 1 addition & 1 deletion ckan/new_tests/logic/auth/test_update.py
Expand Up @@ -50,7 +50,7 @@ def test_user_update_user_cannot_update_another_user(self):
'''Users should not be able to update other users' accounts.'''

fred = factories.User(name='fred')
bob = factories.User(name='bob')
bob = factories.User(name='bob')
fred['name'] = 'updated'

# Make Bob try to update Fred's user account.
Expand Down
8 changes: 5 additions & 3 deletions ckan/new_tests/logic/test_validators.py
Expand Up @@ -366,14 +366,16 @@ def test_user_name_validator_with_a_name_that_already_exists(self):
errors[key] = []

@does_not_modify_other_keys_in_errors_dict('user_name_validator() '
'should not modify other keys in the errors dict')
'should not modify other '
'keys in the errors dict')
@does_not_modify_data_dict('user_name_validator() should not modify '
'the data dict')
@returns_None('user_name_validator() should return None if called '
'with a user name that already exists')
@adds_message_to_errors_dict('That login name is not available.',
'user_name_validator() should add to the errors dict when '
'called with the name of a user that already exists')
'user_name_validator() should add to the '
'errors dict when called with the name '
'of a user that already exists')
def call_validator(*args, **kwargs):
return validators.user_name_validator(*args, **kwargs)
call_validator(key, data, errors, context={'model': mock_model})
Expand Down

0 comments on commit 3a0bb76

Please sign in to comment.