Skip to content

Commit

Permalink
PEP-8 server/ and some of client_admin/.
Browse files Browse the repository at this point in the history
This commit finishes PEP-8'ing the server/ subfolder, as well as three
modules from client_admin/.
  • Loading branch information
Randy Barlow committed Jun 23, 2015
1 parent 6698af3 commit 4271609
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 98 deletions.
6 changes: 2 additions & 4 deletions client_admin/pulp/client/admin/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from gettext import gettext as _
import sys

import pulp.common.tags as tag_utils
from pulp.bindings.exceptions import PulpServerException
Expand Down Expand Up @@ -32,15 +31,14 @@ class BaseTasksSection(PulpCliSection):
to provide consistent functionality for a subset of tasks.
"""

all_flag = PulpCliFlag('--all', _('if specified, all tasks in all states are shown'),
all_flag = PulpCliFlag('--all', _('if specified, all tasks in all states are shown'),
aliases=['-a'])
state_option = PulpCliOption('--state',
_('comma-separated list of tasks states desired to be '
'shown. Example: "running,waiting,canceled,successful,failed". '
'Do not include spaces'), aliases=['-s'], required=False,
parse_func=parsers.csv)


def __init__(self, context, name, description):
PulpCliSection.__init__(self, name, description)
self.context = context
Expand Down Expand Up @@ -162,7 +160,7 @@ def cancel(self, **kwargs):
self.context.prompt.render_failure_message(msg)
return
else:
raise e, None, sys.exc_info()[2]
raise

@staticmethod
def parse_state(task):
Expand Down
4 changes: 1 addition & 3 deletions client_admin/test/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ def test_read_paths(self, fake_config):
@patch('pulp.client.admin.config.Config')
@patch('pulp.client.admin.config.validate_overrides')
def test_read_calls_validate_overrides(self, mock_validate_overrides, fake_config):

# test
cfg = read_config()
read_config()

mock_validate_overrides.assert_called_once()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2012 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

import unittest

Expand All @@ -32,13 +21,13 @@ def test_subsection(self):

class TestGenericSection(unittest.TestCase):
CREATE_ARGS = {
'config' : {'a' : 'foo'},
'event_types' : ['repo-sync-started'],
'notifier_type' : 'email'
'config': {'a': 'foo'},
'event_types': ['repo-sync-started'],
'notifier_type': 'email'
}

def setUp(self):
self.section = event.GenericSection(mock.MagicMock(), 'section' ,'stuff')
self.section = event.GenericSection(mock.MagicMock(), 'section', 'stuff')

def test_create(self):
self.section._create(**self.CREATE_ARGS)
Expand All @@ -62,14 +51,14 @@ def test_empty_update(self):
self.assertEqual(self.section.context.server.event_listener.update.call_count, 0)

def test_update(self):
self.section._update('foo', {'notifier_config': {'a':'bar'}})
self.section._update('foo', {'notifier_config': {'a': 'bar'}})

self.assertEqual(self.section.context.prompt.render_success_message.call_count, 1)
self.section.context.server.event_listener.update.assert_called_once_with(
'foo', notifier_config={'a': 'bar'})

def test_update_event_type(self):
self.section._update('foo', {'event_types' : ['blah']})
self.section._update('foo', {'event_types': ['blah']})

self.assertEqual(self.section.context.prompt.render_success_message.call_count, 1)
self.section.context.server.event_listener.update.assert_called_once_with(
Expand All @@ -96,7 +85,7 @@ def test_list(self):
self.section.context.prompt.render_document.assert_called_once_with({})

def test_delete(self):
args = {'listener-id' : 'foo'}
args = {'listener-id': 'foo'}
self.section.delete(**args)

self.assertEqual(self.section.context.prompt.render_success_message.call_count, 1)
Expand All @@ -110,8 +99,8 @@ def setUp(self):

def test_create(self):
kwargs = {
'event-type' : 'repo-sync-finished',
'exchange' : 'pulp',
'event-type': 'repo-sync-finished',
'exchange': 'pulp',
}
self.section.create(**kwargs)

Expand All @@ -125,9 +114,9 @@ def test_create(self):

def test_update_exchange(self):
kwargs = {
'listener-id' : 'listener1',
'exchange' : 'pulp',
'event-type' : None
'listener-id': 'listener1',
'exchange': 'pulp',
'event-type': None
}

self.section.update(**kwargs)
Expand All @@ -136,9 +125,9 @@ def test_update_exchange(self):

def test_update_exchange_empty(self):
kwargs = {
'listener-id' : 'listener1',
'exchange' : '',
'event-type' : None
'listener-id': 'listener1',
'exchange': '',
'event-type': None
}

self.section.update(**kwargs)
Expand All @@ -152,27 +141,27 @@ def setUp(self):

def test_create(self):
kwargs = {
'event-type' : 'repo-sync-finished',
'subject' : 'hi',
'addresses' : ['[email protected]', '[email protected]']
'event-type': 'repo-sync-finished',
'subject': 'hi',
'addresses': ['[email protected]', '[email protected]']
}
self.section.create(**kwargs)

self.section.context.server.event_listener.create.assert_called_once_with(
'email',
{
'subject': 'hi',
'addresses' : ['[email protected]', '[email protected]']
'addresses': ['[email protected]', '[email protected]']
},
'repo-sync-finished'
)

def test_update_subject(self):
kwargs = {
'listener-id' : 'listener1',
'subject' : 'hi',
'addresses' : None,
'event-type' : None
'listener-id': 'listener1',
'subject': 'hi',
'addresses': None,
'event-type': None
}

self.section.update(**kwargs)
Expand All @@ -181,10 +170,10 @@ def test_update_subject(self):

def test_update_addresses(self):
kwargs = {
'listener-id' : 'listener1',
'subject' : None,
'addresses' : ['[email protected]'],
'event-type' : None
'listener-id': 'listener1',
'subject': None,
'addresses': ['[email protected]'],
'event-type': None
}

self.section.update(**kwargs)
Expand All @@ -193,10 +182,10 @@ def test_update_addresses(self):

def test_update_event_types(self):
kwargs = {
'listener-id' : 'listener1',
'subject' : None,
'addresses' : None,
'event-type' : ['repo-sync-finished']
'listener-id': 'listener1',
'subject': None,
'addresses': None,
'event-type': ['repo-sync-finished']
}

self.section.update(**kwargs)
Expand All @@ -210,8 +199,8 @@ def setUp(self):

def test_create_basic(self):
kwargs = {
'event-type' : 'repo-sync-finished',
'url' : 'http://redhat.com',
'event-type': 'repo-sync-finished',
'url': 'http://redhat.com',
}
self.section.create(**kwargs)

Expand All @@ -223,30 +212,29 @@ def test_create_basic(self):

def test_create_with_username_password(self):
kwargs = {
'event-type' : 'repo-sync-finished',
'url' : 'http://redhat.com',
'username' : 'me',
'password' : 'letmein'
}
'event-type': 'repo-sync-finished',
'url': 'http://redhat.com',
'username': 'me',
'password': 'letmein'}
self.section.create(**kwargs)

self.section.context.server.event_listener.create.assert_called_once_with(
'http',
{
'url': 'http://redhat.com',
'username' : 'me',
'password' : 'letmein'
'username': 'me',
'password': 'letmein'
},
'repo-sync-finished'
)

def test_update_url(self):
kwargs = {
'listener-id' : 'listener1',
'url' : 'http://redhat.com',
'username' : None,
'password' : None,
'event-type' : None,
'listener-id': 'listener1',
'url': 'http://redhat.com',
'username': None,
'password': None,
'event-type': None,
}

self.section.update(**kwargs)
Expand All @@ -255,37 +243,37 @@ def test_update_url(self):

def test_update_username(self):
kwargs = {
'listener-id' : 'listener1',
'url' : None,
'username' : 'me',
'password' : None,
'event-type' : None,
'listener-id': 'listener1',
'url': None,
'username': 'me',
'password': None,
'event-type': None,
}

self.section.update(**kwargs)
self.section.context.server.event_listener.update.assert_called_once_with(
'listener1', notifier_config={'username' : 'me'})
'listener1', notifier_config={'username': 'me'})

def test_update_password(self):
kwargs = {
'listener-id' : 'listener1',
'url' : None,
'username' : None,
'password' : 'letmein',
'event-type' : None,
'listener-id': 'listener1',
'url': None,
'username': None,
'password': 'letmein',
'event-type': None,
}

self.section.update(**kwargs)
self.section.context.server.event_listener.update.assert_called_once_with(
'listener1', notifier_config={'password' : 'letmein'})
'listener1', notifier_config={'password': 'letmein'})

def test_update_event_types(self):
kwargs = {
'listener-id' : 'listener1',
'url' : None,
'username' : None,
'password' : None,
'event-type' : ['repo-sync-finished'],
'listener-id': 'listener1',
'url': None,
'username': None,
'password': None,
'event-type': ['repo-sync-finished'],
}

self.section.update(**kwargs)
Expand Down
7 changes: 4 additions & 3 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
paths_to_check = [
'agent',
'bindings',
'client_admin/pulp/client/admin/tasks.py',
'client_admin/test/unit/test_config.py',
'client_admin/test/unit/test_event.py',
'client_consumer',
'client_lib',
'devel/',
'oid_validation/',
'repoauth/',
'server/pulp/plugins',
'server/pulp/server/',
'server/test/unit/']
'server/']

os.environ['DJANGO_SETTINGS_MODULE'] = 'pulp.server.webservices.settings'

Expand Down
14 changes: 0 additions & 14 deletions server/pulp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2013 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

1 change: 0 additions & 1 deletion server/test/functional/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

0 comments on commit 4271609

Please sign in to comment.