Browse Source

Replace noop tests with registration test

Previously the python tests are just some stub code, replace them with
some real tests.

Change-Id: Iff9006544a361fc2bd0ad562be36efe895ed0d71
Jacky Hu 8 months ago
parent
commit
29487dd38e

+ 0
- 23
neutron_lbaas_dashboard/tests/base.py View File

@@ -1,23 +0,0 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-# Copyright 2010-2011 OpenStack Foundation
4
-# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
5
-#
6
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
-# not use this file except in compliance with the License. You may obtain
8
-# a copy of the License at
9
-#
10
-#      http://www.apache.org/licenses/LICENSE-2.0
11
-#
12
-# Unless required by applicable law or agreed to in writing, software
13
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
-# License for the specific language governing permissions and limitations
16
-# under the License.
17
-
18
-from oslotest import base
19
-
20
-
21
-class TestCase(base.BaseTestCase):
22
-
23
-    """Test case base class for all unit tests."""

+ 0
- 78
neutron_lbaas_dashboard/tests/integration_tests/horizon.conf View File

@@ -1,78 +0,0 @@
1
-#
2
-# Configuration filed based on Tempest's tempest.conf.sample
3
-#
4
-
5
-[dashboard]
6
-# Where the dashboard can be found (string value)
7
-dashboard_url=http://localhost/dashboard/
8
-
9
-# Login page for the dashboard (string value)
10
-login_url=http://localhost/dashboard/auth/login/
11
-
12
-# Dashboard help page url (string value)
13
-help_url=http://docs.openstack.org/
14
-
15
-[selenium]
16
-# Timeout in seconds to wait for a page to become available
17
-# (integer value)
18
-page_timeout=30
19
-
20
-# Output directory for screenshots.
21
-# (string value)
22
-screenshots_directory=integration_tests_screenshots
23
-
24
-# Implicit timeout to wait until element become available,
25
-# this timeout is used for every find_element, find_elements call.
26
-# (integer value)
27
-implicit_wait=10
28
-
29
-# Explicit timeout is used for long lasting operations,
30
-# methods using explicit timeout are usually prefixed with 'wait',
31
-# those methods ignore implicit_wait when looking up web elements.
32
-# (integer value)
33
-explicit_wait=300
34
-
35
-[image]
36
-# http accessible image (string value)
37
-http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
38
-
39
-[identity]
40
-# Username to use for non-admin API requests. (string value)
41
-username=demo
42
-
43
-# API key to use when authenticating. (string value)
44
-password=secretadmin
45
-
46
-# Administrative Username to use for admin API requests.
47
-# (string value)
48
-admin_username=admin
49
-
50
-# API key to use when authenticating as admin. (string value)
51
-admin_password=secretadmin
52
-
53
-[scenario]
54
-# ssh username for image file (string value)
55
-ssh_user=cirros
56
-
57
-[launch_instances]
58
-#available zone to launch instances
59
-available_zone=nova
60
-#image_name to launch instances
61
-image_name=cirros-0.3.4-x86_64-uec (24.0 MB)
62
-
63
-[plugin]
64
-
65
-is_plugin=True
66
-plugin_page_path=neutron_lbaas_dashboard.tests.integration_tests.pages
67
-plugin_page_structure={
68
-            "Project":
69
-                {
70
-                    "Network":
71
-                        {
72
-                            "-":
73
-                                [
74
-                                    "Load Balancers"
75
-                                ]
76
-                        }
77
-                }
78
-        }

+ 0
- 0
neutron_lbaas_dashboard/tests/integration_tests/pages/__init__.py View File


+ 0
- 0
neutron_lbaas_dashboard/tests/integration_tests/pages/project/__init__.py View File


+ 0
- 0
neutron_lbaas_dashboard/tests/integration_tests/pages/project/network/__init__.py View File


+ 0
- 0
neutron_lbaas_dashboard/tests/integration_tests/tests/__init__.py View File


+ 0
- 27
neutron_lbaas_dashboard/tests/integration_tests/tests/test_loadbalancers.py View File

@@ -1,27 +0,0 @@
1
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
2
-#    not use this file except in compliance with the License. You may obtain
3
-#    a copy of the License at
4
-#
5
-#         http://www.apache.org/licenses/LICENSE-2.0
6
-#
7
-#    Unless required by applicable law or agreed to in writing, software
8
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
-#    License for the specific language governing permissions and limitations
11
-#    under the License.
12
-
13
-from openstack_dashboard.test.integration_tests import helpers
14
-
15
-
16
-class TestLoadbalancers(helpers.TestCase):
17
-
18
-    def setUp(self):
19
-        super(TestLoadbalancers, self).setUp()
20
-        self.home_pg.go_to_network_loadbalancerspage()
21
-
22
-    def test_loadbalancers(self):
23
-        self._save_screenshot(None)
24
-        # TODO(MRV): Place holder for tests
25
-
26
-    def tearDown(self):
27
-        super(TestLoadbalancers, self).tearDown()

+ 20
- 169
neutron_lbaas_dashboard/tests/settings.py View File

@@ -1,3 +1,4 @@
1
+# Copyright 2018 Walmart.
1 2
 #
2 3
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
3 4
 #    not use this file except in compliance with the License. You may obtain
@@ -11,178 +12,28 @@
11 12
 #    License for the specific language governing permissions and limitations
12 13
 #    under the License.
13 14
 
14
-import importlib
15
-import os
16
-import six
17
-
15
+# Default to Horizons test settings to avoid any missing keys
18 16
 from horizon.test.settings import *  # noqa
19
-from horizon.utils import secret_key
20
-from openstack_dashboard import exceptions
21
-
22
-
23
-DEBUG = True
24
-TEMPLATE_DEBUG = DEBUG
25
-
26
-TEST_DIR = os.path.dirname(os.path.abspath(__file__))
27
-ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
17
+from openstack_dashboard.test.settings import *  # noqa
28 18
 
29
-MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media'))
30
-MEDIA_URL = '/media/'
31
-STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
32
-STATIC_URL = '/static/'
33
-
34
-SECRET_KEY = secret_key.generate_or_read_from_file(
35
-    os.path.join(TEST_DIR, '.secret_key_store'))
36
-ROOT_URLCONF = 'neutron_lbaas_dashboard.tests.urls'
37
-TEMPLATE_DIRS = (
38
-    os.path.join(TEST_DIR, 'templates'),
39
-)
40
-
41
-TEMPLATE_CONTEXT_PROCESSORS += (
42
-    'openstack_dashboard.context_processors.openstack',
43
-)
19
+# pop these keys to avoid log warnings about deprecation
20
+# update_dashboards will populate them anyway
21
+HORIZON_CONFIG.pop('dashboards', None)
22
+HORIZON_CONFIG.pop('default_dashboard', None)
44 23
 
45
-INSTALLED_APPS = (
46
-    'django.contrib.contenttypes',
47
-    'django.contrib.auth',
48
-    'django.contrib.sessions',
49
-    'django.contrib.staticfiles',
50
-    'django.contrib.messages',
51
-    'django.contrib.humanize',
52
-    'django_nose',
53
-    'openstack_auth',
54
-    'compressor',
55
-    'horizon',
56
-    'openstack_dashboard',
57
-    'openstack_dashboard.dashboards',
58
-)
59
-
60
-AUTHENTICATION_BACKENDS = ('openstack_auth.backend.KeystoneBackend',)
61
-
62
-SITE_BRANDING = 'OpenStack'
63
-
64
-HORIZON_CONFIG = {
65
-    "password_validator": {
66
-        "regex": '^.{8,18}$',
67
-        "help_text": "Password must be between 8 and 18 characters."
68
-    },
69
-    'user_home': None,
70
-    'help_url': "http://docs.openstack.org",
71
-    'exceptions': {'recoverable': exceptions.RECOVERABLE,
72
-                   'not_found': exceptions.NOT_FOUND,
73
-                   'unauthorized': exceptions.UNAUTHORIZED},
74
-    'angular_modules': [],
75
-    'js_files': [],
76
-}
77
-
78
-# Load the pluggable dashboard settings
24
+# Update the dashboards with octavia_dashboard
25
+import neutron_lbaas_dashboard.enabled
26
+import openstack_dashboard.enabled
79 27
 from openstack_dashboard.utils import settings
80
-dashboard_module_names = [
81
-    'openstack_dashboard.enabled',
82
-    'openstack_dashboard.local.enabled',
83
-    'neutron_lbaas_dashboard.enabled',
84
-]
85
-dashboard_modules = []
86
-# All dashboards must be enabled for the namespace to get registered, which is
87
-# needed by the unit tests.
88
-for module_name in dashboard_module_names:
89
-    module = importlib.import_module(module_name)
90
-    dashboard_modules.append(module)
91
-    for submodule in six.itervalues(settings.import_submodules(module)):
92
-        if getattr(submodule, 'DISABLED', None):
93
-            delattr(submodule, 'DISABLED')
94
-INSTALLED_APPS = list(INSTALLED_APPS)  # Make sure it's mutable
95
-settings.update_dashboards(dashboard_modules, HORIZON_CONFIG, INSTALLED_APPS)
96
-
97
-
98
-# Set to True to allow users to upload images to glance via Horizon server.
99
-# When enabled, a file form field will appear on the create image form.
100
-# See documentation for deployment considerations.
101
-HORIZON_IMAGES_ALLOW_UPLOAD = True
102 28
 
103
-AVAILABLE_REGIONS = [
104
-    ('http://localhost/identity', 'local'),
105
-    ('http://remote/identity', 'remote'),
106
-]
107
-
108
-OPENSTACK_API_VERSIONS = {
109
-    "identity": 3
110
-}
111
-
112
-OPENSTACK_KEYSTONE_URL = "http://localhost/identity"
113
-OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
114
-
115
-OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
116
-OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'test_domain'
117
-
118
-OPENSTACK_KEYSTONE_BACKEND = {
119
-    'name': 'native',
120
-    'can_edit_user': True,
121
-    'can_edit_group': True,
122
-    'can_edit_project': True,
123
-    'can_edit_domain': True,
124
-    'can_edit_role': True
125
-}
126
-
127
-OPENSTACK_CINDER_FEATURES = {
128
-    'enable_backup': True,
129
-}
130
-
131
-OPENSTACK_NEUTRON_NETWORK = {
132
-    'enable_lb': False,
133
-    'enable_firewall': False,
134
-    'enable_vpn': False
135
-}
136
-
137
-OPENSTACK_HYPERVISOR_FEATURES = {
138
-    'can_set_mount_point': True,
139
-
140
-    # NOTE: as of Grizzly this is not yet supported in Nova so enabling this
141
-    # setting will not do anything useful
142
-    'can_encrypt_volumes': False
143
-}
144
-
145
-LOGGING['loggers']['openstack_dashboard'] = {
146
-    'handlers': ['test'],
147
-    'propagate': False,
148
-}
149
-
150
-LOGGING['loggers']['selenium'] = {
151
-    'handlers': ['test'],
152
-    'propagate': False,
153
-}
154
-
155
-LOGGING['loggers']['neutron_lbaas_dashboard'] = {
156
-    'handlers': ['test'],
157
-    'propagate': False,
158
-}
159
-
160
-SECURITY_GROUP_RULES = {
161
-    'all_tcp': {
162
-        'name': 'ALL TCP',
163
-        'ip_protocol': 'tcp',
164
-        'from_port': '1',
165
-        'to_port': '65535',
166
-    },
167
-    'http': {
168
-        'name': 'HTTP',
169
-        'ip_protocol': 'tcp',
170
-        'from_port': '80',
171
-        'to_port': '80',
172
-    },
173
-}
174
-
175
-NOSE_ARGS = ['--nocapture',
176
-             '--nologcapture',
177
-             '--cover-package=openstack_dashboard',
178
-             '--cover-inclusive',
179
-             '--all-modules']
180
-
181
-POLICY_FILES_PATH = os.path.join(ROOT_PATH, "conf")
182
-POLICY_FILES = {
183
-    'identity': 'keystone_policy.json',
184
-    'compute': 'nova_policy.json'
185
-}
29
+settings.update_dashboards(
30
+    [
31
+        neutron_lbaas_dashboard.enabled,
32
+        openstack_dashboard.enabled,
33
+    ],
34
+    HORIZON_CONFIG,
35
+    INSTALLED_APPS
36
+)
186 37
 
187
-# The openstack_auth.user.Token object isn't JSON-serializable ATM
188
-SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
38
+# Ensure any duplicate apps are removed after the update_dashboards call
39
+INSTALLED_APPS = list(set(INSTALLED_APPS))

+ 0
- 28
neutron_lbaas_dashboard/tests/test_neutron_lbaas_dashboard.py View File

@@ -1,28 +0,0 @@
1
-# -*- coding: utf-8 -*-
2
-
3
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-# not use this file except in compliance with the License. You may obtain
5
-# a copy of the License at
6
-#
7
-#      http://www.apache.org/licenses/LICENSE-2.0
8
-#
9
-# Unless required by applicable law or agreed to in writing, software
10
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-# License for the specific language governing permissions and limitations
13
-# under the License.
14
-
15
-"""
16
-test_neutron_lbaas_dashboard
17
-----------------------------------
18
-
19
-Tests for `neutron_lbaas_dashboard` module.
20
-"""
21
-
22
-from neutron_lbaas_dashboard.tests import base
23
-
24
-
25
-class TestNeutron_lbaas_dashboard(base.TestCase):
26
-
27
-    def test_something(self):
28
-        pass

neutron_lbaas_dashboard/tests/integration_tests/__init__.py → neutron_lbaas_dashboard/tests/unit/__init__.py View File


neutron_lbaas_dashboard/tests/integration_tests/pages/project/network/loadbalancerspage.py → neutron_lbaas_dashboard/tests/unit/registration.py View File

@@ -1,3 +1,5 @@
1
+# Copyright 2018 Walmart.
2
+#
1 3
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
2 4
 #    not use this file except in compliance with the License. You may obtain
3 5
 #    a copy of the License at
@@ -10,13 +12,15 @@
10 12
 #    License for the specific language governing permissions and limitations
11 13
 #    under the License.
12 14
 
13
-from openstack_dashboard.test.integration_tests.pages import basepage
14
-
15
+import horizon
16
+from neutron_lbaas_dashboard.dashboards.project.ngloadbalancersv2 \
17
+    import panel as n_panel
18
+from openstack_dashboard.test import helpers as test
15 19
 
16
-class LoadbalancersPage(basepage.BaseNavigationPage):
17 20
 
18
-    TABLE_IMAGE_COLUMN = 'name'
21
+class RegistrationTests(test.TestCase):
22
+    def test_registered(self):
23
+        dashboard = horizon.get_dashboard('project')
24
+        panel = dashboard.get_panel('ngloadbalancersv2')
19 25
 
20
-    def __init__(self, driver, conf):
21
-        super(LoadbalancersPage, self).__init__(driver, conf)
22
-        self._page_title = "Load Balancers"
26
+        self.assertEqual(panel.__class__, n_panel.NGLoadBalancers)

+ 4
- 3
neutron_lbaas_dashboard/tests/urls.py View File

@@ -11,9 +11,10 @@
11 11
 #    License for the specific language governing permissions and limitations
12 12
 #    under the License.
13 13
 
14
-from django.conf import urls
15
-from openstack_dashboard import urls as dashboard_urls
14
+from django.conf.urls import include
15
+from django.conf.urls import url
16
+import openstack_dashboard.urls
16 17
 
17 18
 urlpatterns = [
18
-    urls.url(r'', urls.include(dashboard_urls))
19
+    url(r'', include(openstack_dashboard.urls))
19 20
 ]

+ 2
- 1
tox.ini View File

@@ -14,12 +14,13 @@ setenv =
14 14
    NOSE_OPENSTACK_YELLOW=0.025
15 15
    NOSE_OPENSTACK_SHOW_ELAPSED=1
16 16
    CLIENT_NAME=neutron-lbaas-dashboard
17
+   DJANGO_SETTINGS_MODULE=neutron_lbaas_dashboard.tests.settings
17 18
 deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
18 19
        -r{toxinidir}/requirements.txt
19 20
        -r{toxinidir}/test-requirements.txt
20 21
 whitelist_externals = npm
21 22
                       bash
22
-commands = python manage.py test
23
+commands = python manage.py test neutron_lbaas_dashboard --settings=neutron_lbaas_dashboard.tests.settings
23 24
 
24 25
 [testenv:pep8]
25 26
 commands = flake8

Loading…
Cancel
Save