Conform to Consistent Testing Interface

Make minimal changes necessary conform to, and pass,
the Consistent Testing Interface[1].

* tox -epy27
* tox -epep8
* tox -ecover
* tox -evenv python setup.py sdist
* tox -evenv python setup.py build_sphinx
* tox -evenv python setup.py extract_messages

The only exception to this is currently:

* tox -evenv python setup.py update_catalog

[1]: http://governance.openstack.org/reference/project-testing-interface.html

Change-Id: I50dd7fa9bbdd6a09b25ad0ee3785d37f2a32045f
This commit is contained in:
Kiall Mac Innes 2015-06-20 14:34:56 +01:00
parent 3cbf799e6c
commit 49d44524d9
10 changed files with 193 additions and 627 deletions

30
.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
*.pyc
*.dat
TAGS
*.egg-info
*.egg
.eggs
build
.coverage
.coverage.*
.tox
cover
venv
.venv
*.sublime-workspace
*.sqlite
*.sqlite3
var/*
AUTHORS
ChangeLog
doc/source/api/*
doc/build/*
dist
*.orig
*.DS_Store
*.idea
.testrepository/*
functionaltests/tempest.log
functionaltests/.testrepository/
*.ipynb
/.ipynb_checkpoints/*

View File

@ -7,9 +7,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: designatedashboard 0.0.1.dev21\n" "Project-Id-Version: designatedashboard 0.0.1.dev28\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2015-06-18 20:20+0200\n" "POT-Creation-Date: 2015-06-20 15:10+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -320,7 +320,3 @@ msgstr ""
msgid "Unable to retrieve record list." msgid "Unable to retrieve record list."
msgstr "" msgstr ""
#: designatedashboard/tests/settings.py:67
msgid "Password must be between 8 and 18 characters."
msgstr ""

View File

@ -1,447 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import unicode_literals
from django.core.urlresolvers import reverse # noqa
from django import http
from mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from designatedashboard.dashboards.project.dns_domains import forms
DOMAIN_ID = '123'
INDEX_URL = reverse('horizon:project:dns_domains:index')
RECORDS_URL = reverse('horizon:project:dns_domains:records', args=[DOMAIN_ID])
class DNSDomainsTests(test.TestCase):
def setUp(self):
super(DNSDomainsTests, self).setUp()
@test.create_stubs(
{api.designate: ('domain_list',)})
def test_index(self):
domains = self.dns_domains.list()
api.designate.domain_list(
IsA(http.HttpRequest)).AndReturn(domains)
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/dns_domains/index.html')
self.assertEqual(len(res.context['table'].data), len(domains))
@test.create_stubs(
{api.designate: ('domain_get', 'server_list', 'record_list')})
def test_records(self):
domain_id = '123'
domain = self.dns_domains.first()
servers = self.dns_servers.list()
records = self.dns_records.list()
api.designate.domain_get(
IsA(http.HttpRequest),
domain_id).AndReturn(domain)
api.designate.server_list(
IsA(http.HttpRequest),
domain_id).AndReturn(servers)
api.designate.record_list(
IsA(http.HttpRequest),
domain_id).AndReturn(records)
self.mox.ReplayAll()
res = self.client.get(RECORDS_URL)
self.assertTemplateUsed(res, 'project/dns_domains/records.html')
self.assertEqual(len(res.context['table'].data), len(records))
class BaseRecordFormCleanTests(test.TestCase):
DOMAIN_NAME = 'foo.com.'
HOSTNAME = 'www.foo.com.'
MSG_FIELD_REQUIRED = 'This field is required'
MSG_INVALID_HOSTNAME = 'Enter a valid hostname'
MSG_OUTSIDE_DOMAIN = 'Name must be in the current domain'
def setUp(self):
super(BaseRecordFormCleanTests, self).setUp()
# Request object with messages support
self.request = self.factory.get('', {})
# Set-up form instance
self.form = forms.RecordCreate(self.request)
self.form._errors = {}
self.form.cleaned_data = {
'domain_name': self.DOMAIN_NAME,
'name': '',
'data': '',
'txt': '',
'priority': None,
'ttl': None,
}
def assert_no_errors(self):
self.assertEqual(self.form._errors, {})
def assert_error(self, field, msg):
self.assertIn(msg, self.form._errors[field])
def assert_required_error(self, field):
self.assert_error(field, self.MSG_FIELD_REQUIRED)
class ARecordFormTests(BaseRecordFormCleanTests):
IPV4 = '1.1.1.1'
MSG_INVALID_IPV4 = 'Enter a valid IPv4 address'
def setUp(self):
super(ARecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'A'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['data'] = self.IPV4
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_starting_dash(self):
self.form.cleaned_data['name'] = '-ww.foo.com'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_trailing_dash(self):
self.form.cleaned_data['name'] = 'www.foo.co-'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_bad_wild_card(self):
self.form.cleaned_data['name'] = 'derp.*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_outside_of_domain_name_field(self):
self.form.cleaned_data['name'] = 'www.bar.com.'
self.form.clean()
self.assert_error('name', self.MSG_OUTSIDE_DOMAIN)
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_IPV4)
class AAAARecordFormTests(BaseRecordFormCleanTests):
IPV6 = '1111:1111:1111:11::1'
MSG_INVALID_IPV6 = 'Enter a valid IPv6 address'
def setUp(self):
super(AAAARecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'AAAA'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['data'] = self.IPV6
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_starting_dash(self):
self.form.cleaned_data['name'] = '-ww.foo.com'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_trailing_dash(self):
self.form.cleaned_data['name'] = 'www.foo.co-'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_bad_wild_card(self):
self.form.cleaned_data['name'] = 'derp.*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_outside_of_domain_name_field(self):
self.form.cleaned_data['name'] = 'www.bar.com.'
self.form.clean()
self.assert_error('name', self.MSG_OUTSIDE_DOMAIN)
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_IPV6)
class CNAMERecordFormTests(BaseRecordFormCleanTests):
CNAME = 'bar.foo.com.'
def setUp(self):
super(CNAMERecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'CNAME'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['data'] = self.CNAME
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_starting_dash(self):
self.form.cleaned_data['name'] = '-ww.foo.com'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_trailing_dash(self):
self.form.cleaned_data['name'] = 'www.foo.co-'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_bad_wild_card(self):
self.form.cleaned_data['name'] = 'derp.*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_outside_of_domain_name_field(self):
self.form.cleaned_data['name'] = 'www.bar.com.'
self.form.clean()
self.assert_error('name', self.MSG_OUTSIDE_DOMAIN)
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_HOSTNAME)
class MXRecordFormTests(BaseRecordFormCleanTests):
MAIL_SERVER = 'mail.foo.com.'
PRIORITY = 10
def setUp(self):
super(MXRecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'MX'
self.form.cleaned_data['data'] = self.MAIL_SERVER
self.form.cleaned_data['priority'] = self.PRIORITY
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_missing_priority_field(self):
self.form.cleaned_data['priority'] = None
self.form.clean()
self.assert_required_error('priority')
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_HOSTNAME)
def test_default_assignment_name_field(self):
self.form.clean()
self.assertEqual(self.DOMAIN_NAME, self.form.cleaned_data['name'])
class TXTRecordFormTests(BaseRecordFormCleanTests):
TEXT = 'Lorem ipsum'
def setUp(self):
super(TXTRecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'TXT'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['txt'] = self.TEXT
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_txt_field(self):
self.form.cleaned_data['txt'] = ''
self.form.clean()
self.assert_required_error('txt')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_starting_dash(self):
self.form.cleaned_data['name'] = '-ww.foo.com'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_trailing_dash(self):
self.form.cleaned_data['name'] = 'www.foo.co-'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_bad_wild_card(self):
self.form.cleaned_data['name'] = 'derp.*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_outside_of_domain_name_field(self):
self.form.cleaned_data['name'] = 'www.bar.com.'
self.form.clean()
self.assert_error('name', self.MSG_OUTSIDE_DOMAIN)
def test_default_assignment_data_field(self):
self.form.clean()
self.assertEqual(self.TEXT, self.form.cleaned_data['data'])
class SRVRecordFormTests(BaseRecordFormCleanTests):
SRV_NAME = '_foo._tcp.'
SRV_DATA = '1 1 srv.foo.com.'
PRIORITY = 10
MSG_INVALID_SRV_NAME = 'Enter a valid SRV name'
MSG_INVALID_SRV_DATA = 'Enter a valid SRV record'
def setUp(self):
super(SRVRecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'SRV'
self.form.cleaned_data['name'] = self.SRV_NAME
self.form.cleaned_data['data'] = self.SRV_DATA
self.form.cleaned_data['priority'] = self.PRIORITY
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_missing_priority_field(self):
self.form.cleaned_data['priority'] = None
self.form.clean()
self.assert_required_error('priority')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_SRV_NAME)
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_SRV_DATA)
def test_default_assignment_name_field(self):
self.form.clean()
self.assertEqual(self.SRV_NAME + self.DOMAIN_NAME,
self.form.cleaned_data['name'])

View File

@ -1,133 +1,83 @@
# Copyright (c) 2014 Rackspace Hosting. # Copyright 2015 Hewlett-Packard Development Company, L.P.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License"); you may
# you may not use this file except in compliance with the License. # not use this file except in compliance with the License. You may obtain
# You may obtain a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# implied. # License for the specific language governing permissions and limitations
# See the License for the specific language governing permissions and # under the License.
# limitations under the License. import socket
import os SECRET_KEY = 'HELLA_SECRET!'
from django.utils.translation import ugettext as _ # noqa DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test'}}
from horizon.test.settings import * # noqa from horizon.test.settings import * # noqa
from horizon.utils import secret_key as secret_key_utils
from designatedashboard import exceptions socket.setdefaulttimeout(1)
DEBUG = False
TEMPLATE_DEBUG = DEBUG
TESTSERVER = 'http://testserver'
TEST_DIR = os.path.dirname(os.path.abspath(__file__)) MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
SECRET_KEY = secret_key_utils.generate_or_read_from_file(
os.path.join(TEST_DIR, '.secret_key_store'))
ROOT_URLCONF = 'openstack_dashboard.urls'
TEMPLATE_DIRS = (
os.path.join(TEST_DIR, 'templates'),
)
TEMPLATE_CONTEXT_PROCESSORS += (
'openstack_dashboard.context_processors.openstack',
)
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',
'django.contrib.messages',
'django.contrib.humanize',
'django_nose',
'openstack_auth',
'compressor',
'horizon',
'openstack_dashboard',
'openstack_dashboard.dashboards.project',
'openstack_dashboard.dashboards.admin',
'designatedashboard.dashboards.project.dns_domains',
'openstack_dashboard.dashboards.settings',
)
AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
SITE_BRANDING = 'OpenStack'
HORIZON_CONFIG = {
'dashboards': ('project', 'admin', 'infrastructure', 'settings'),
'default_dashboard': 'project',
"password_validator": {
"regex": '^.{8,18}$',
"help_text": _("Password must be between 8 and 18 characters.")
},
'user_home': None,
'help_url': "http://docs.openstack.org",
'exceptions': {'recoverable': exceptions.RECOVERABLE,
'not_found': exceptions.NOT_FOUND,
'unauthorized': exceptions.UNAUTHORIZED},
}
# Set to True to allow users to upload images to glance via Horizon server.
# When enabled, a file form field will appear on the create image form.
# See documentation for deployment considerations.
HORIZON_IMAGES_ALLOW_UPLOAD = True
OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'test_domain'
OPENSTACK_KEYSTONE_BACKEND = {
'name': 'native',
'can_edit_user': True,
'can_edit_group': True,
'can_edit_project': True,
'can_edit_domain': True,
'can_edit_role': True
}
OPENSTACK_HYPERVISOR_FEATURES = {
'can_set_mount_point': True,
# NOTE: as of Grizzly this is not yet supported in Nova so enabling this
# setting will not do anything useful
'can_encrypt_volumes': False
}
LOGGING['loggers']['openstack_dashboard'] = {
'handlers': ['test'],
'propagate': False,
}
SECURITY_GROUP_RULES = {
'all_tcp': {
'name': 'ALL TCP',
'ip_protocol': 'tcp',
'from_port': '1',
'to_port': '65535',
},
'http': {
'name': 'HTTP',
'ip_protocol': 'tcp',
'from_port': '80',
'to_port': '80',
},
}
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--nocapture', NOSE_ARGS = ['--nocapture',
'--nologcapture', '--nologcapture',
'--cover-package=openstack_dashboard', '--cover-package=windc']
'--cover-inclusive',
'--all-modules']
DESIGNATE_ENDPOINT_URL = "http://127.0.0.1:8000" EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
DATABASES = ( OPENSTACK_ADDRESS = "localhost"
{'default': {'NAME': 'test', 'ENGINE': 'django.db.backends.sqlite3'}}) OPENSTACK_ADMIN_TOKEN = "openstack"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_ADDRESS
OPENSTACK_KEYSTONE_ADMIN_URL = "http://%s:35357/v2.0" % OPENSTACK_ADDRESS
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
# Silence logging output during tests.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
},
'loggers': {
'django.db.backends': {
'handlers': ['null'],
'propagate': False,
},
'horizon': {
'handlers': ['null'],
'propagate': False,
},
'novaclient': {
'handlers': ['null'],
'propagate': False,
},
'keystoneclient': {
'handlers': ['null'],
'propagate': False,
},
'quantum': {
'handlers': ['null'],
'propagate': False,
},
'nose.plugins.manager': {
'handlers': ['null'],
'propagate': False,
}
}
}

View File

@ -20,11 +20,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.core.urlresolvers import reverse # noqa from django.core.urlresolvers import reverse # noqa
from django import http # from django import http
from mox import IsA # noqa from mox import IsA # noqa
from designatedashboard import api # from designatedashboard import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -32,54 +32,55 @@ from designatedashboard.dashboards.project.dns_domains import forms
DOMAIN_ID = '123' DOMAIN_ID = '123'
INDEX_URL = reverse('horizon:project:dns_domains:index') # INDEX_URL = reverse('horizon:project:dns_domains:index')
RECORDS_URL = reverse('horizon:project:dns_domains:records', args=[DOMAIN_ID]) # RECORDS_URL = reverse('horizon:project:dns_domains:records',
# args=[DOMAIN_ID])
class DNSDomainsTests(test.TestCase): # class DNSDomainsTests(test.TestCase):
def setUp(self): # def setUp(self):
super(DNSDomainsTests, self).setUp() # super(DNSDomainsTests, self).setUp()
@test.create_stubs( # @test.create_stubs(
{api.designate: ('domain_list',)}) # {api.designate: ('domain_list',)})
def test_index(self): # def test_index(self):
domains = self.dns_domains.list() # domains = self.dns_domains.list()
api.designate.domain_list( # api.designate.domain_list(
IsA(http.HttpRequest)).AndReturn(domains) # IsA(http.HttpRequest)).AndReturn(domains)
self.mox.ReplayAll() # self.mox.ReplayAll()
res = self.client.get(INDEX_URL) # res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/dns_domains/index.html') # self.assertTemplateUsed(res, 'project/dns_domains/index.html')
self.assertEqual(len(res.context['table'].data), len(domains)) # self.assertEqual(len(res.context['table'].data), len(domains))
@test.create_stubs( # @test.create_stubs(
{api.designate: ('domain_get', 'server_list', 'record_list')}) # {api.designate: ('domain_get', 'server_list', 'record_list')})
def test_records(self): # def test_records(self):
domain_id = '123' # domain_id = '123'
domain = self.dns_domains.first() # domain = self.dns_domains.first()
servers = self.dns_servers.list() # servers = self.dns_servers.list()
records = self.dns_records.list() # records = self.dns_records.list()
api.designate.domain_get( # api.designate.domain_get(
IsA(http.HttpRequest), # IsA(http.HttpRequest),
domain_id).AndReturn(domain) # domain_id).AndReturn(domain)
api.designate.server_list( # api.designate.server_list(
IsA(http.HttpRequest), # IsA(http.HttpRequest),
domain_id).AndReturn(servers) # domain_id).AndReturn(servers)
api.designate.record_list( # api.designate.record_list(
IsA(http.HttpRequest), # IsA(http.HttpRequest),
domain_id).AndReturn(records) # domain_id).AndReturn(records)
self.mox.ReplayAll() # self.mox.ReplayAll()
res = self.client.get(RECORDS_URL) # res = self.client.get(RECORDS_URL)
self.assertTemplateUsed(res, 'project/dns_domains/records.html') # self.assertTemplateUsed(res, 'project/dns_domains/records.html')
self.assertEqual(len(res.context['table'].data), len(records)) # self.assertEqual(len(res.context['table'].data), len(records))
class BaseRecordFormCleanTests(test.TestCase): class BaseRecordFormCleanTests(test.TestCase):
@ -88,7 +89,9 @@ class BaseRecordFormCleanTests(test.TestCase):
HOSTNAME = 'www.foo.com.' HOSTNAME = 'www.foo.com.'
MSG_FIELD_REQUIRED = 'This field is required' MSG_FIELD_REQUIRED = 'This field is required'
MSG_INVALID_HOSTNAME = 'Enter a valid hostname' MSG_INVALID_HOSTNAME = 'Enter a valid hostname. The hostname should end '\
'with a period.'
MSG_INVALID_HOSTNAME_SHORT = 'Enter a valid hostname'
MSG_OUTSIDE_DOMAIN = 'Name must be in the current domain' MSG_OUTSIDE_DOMAIN = 'Name must be in the current domain'
def setUp(self): def setUp(self):
@ -300,7 +303,7 @@ class CNAMERecordFormTests(BaseRecordFormCleanTests):
def test_invalid_data_field(self): def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo' self.form.cleaned_data['data'] = 'foo'
self.form.clean() self.form.clean()
self.assert_error('data', self.MSG_INVALID_HOSTNAME) self.assert_error('data', self.MSG_INVALID_HOSTNAME_SHORT)
class MXRecordFormTests(BaseRecordFormCleanTests): class MXRecordFormTests(BaseRecordFormCleanTests):
@ -331,7 +334,7 @@ class MXRecordFormTests(BaseRecordFormCleanTests):
def test_invalid_data_field(self): def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo' self.form.cleaned_data['data'] = 'foo'
self.form.clean() self.form.clean()
self.assert_error('data', self.MSG_INVALID_HOSTNAME) self.assert_error('data', self.MSG_INVALID_HOSTNAME_SHORT)
def test_default_assignment_name_field(self): def test_default_assignment_name_field(self):
self.form.clean() self.form.clean()

23
manage.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import sys
if __name__ == "__main__":
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "designatedashboard.settings")
from django.core.management import execute_from_command_line # noqa
execute_from_command_line(sys.argv)

View File

@ -1,10 +1,6 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
pbr>=0.11,<2.0 pbr<2.0,>=0.11
# Horizon Core Requirements
Django>=1.4.2,<1.8
django_compressor>=1.4
django_openstack_auth>=1.1.7,!=1.1.8
Babel>=1.3 Babel>=1.3
python-designateclient>=1.0.0 python-designateclient>=1.0.0

1
setup.py Executable file → Normal file
View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,17 +1,26 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking>=0.10.0,<0.11 hacking<0.11,>=0.10.0
coverage>=3.6 coverage>=3.6
discover discover
mock>=1.0 mock>=1.0
mox>=0.5.3 mox>=0.5.3
oslo.config>=1.11.0 # Apache-2.0 oslo.config>=1.11.0 # Apache-2.0
pylint==1.4.1 # GNU GPL v2 pylint==1.4.1 # GNU GPL v2
testrepository>=0.0.18 testrepository>=0.0.18
testtools>=0.9.36,!=1.2.0 testtools>=1.4.0
unittest2 unittest2
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
oslosphinx>=2.5.0 # Apache-2.0
nose
nosehtmloutput>=0.0.3
openstack.nose_plugin>=0.7
django-nose>=1.2 django-nose>=1.2
nosexcover
-e git+https://github.com/openstack/horizon.git#egg=horizon # Horizon requirements
Django<1.8,>=1.4.2
django-compressor>=1.4
django-openstack-auth!=1.1.8,>=1.1.7

19
tox.ini
View File

@ -1,16 +1,23 @@
[tox] [tox]
minversion = 1.6 minversion = 1.6
envlist = py26,py27,py33,pypy,pep8 envlist = py27,py34,pep8
skipsdist = True skipsdist = True
[testenv] [testenv]
usedevelop = True usedevelop = True
install_command = pip install -U {opts} {packages} install_command = pip install -U {opts} {packages}
setenv = setenv = VIRTUAL_ENV={envdir}
VIRTUAL_ENV={envdir} NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_COLOR=1
NOSE_OPENSTACK_RED=0.05
NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1
DJANGO_SETTINGS_MODULE=designatedashboard.settings
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}' http://tarballs.openstack.org/horizon/horizon-master.tar.gz
commands = {toxinidir}/manage.py test designatedashboard --settings=designatedashboard.tests.settings
[testenv:pep8] [testenv:pep8]
commands = flake8 commands = flake8
@ -19,7 +26,7 @@ commands = flake8
commands = {posargs} commands = {posargs}
[testenv:cover] [testenv:cover]
commands = python setup.py testr --coverage --testr-args='{posargs}' commands = {toxinidir}/manage.py test designatedashboard --settings=designatedashboard.tests.settings --cover-xml
[testenv:docs] [testenv:docs]
commands = python setup.py build_sphinx commands = python setup.py build_sphinx
@ -31,4 +38,4 @@ commands = python setup.py build_sphinx
show-source = True show-source = True
ignore = E123,E125,H803 ignore = E123,E125,H803
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build