aboutsummaryrefslogtreecommitdiffstats
path: root/tests/uiTests/test_detailed_view.py
blob: e9870b885a120768f28b4c0e2ab1055b48e8eb85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# ============LICENSE_START==========================================
# org.onap.vvp/test-engine
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# under the Apache License, Version 2.0 (the “License”);
# you may not use this software 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.
#
#
#
# Unless otherwise specified, all documentation contained herein is licensed
# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
#             https://creativecommons.org/licenses/by/4.0/
#
# Unless required by applicable law or agreed to in writing, documentation
# 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.
#
# ============LICENSE_END============================================
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
import uuid

from iceci.decorator.exception_decor import exception
from services.constants import Constants
from services.helper import Helper
from services.logging_service import LoggingServiceFactory
from services.session import session
from services.types import API, DB, Frontend
from tests.uiTests.test_ui_base import TestUiBase


logger = LoggingServiceFactory.get_logger()


class TestDetailedView(TestUiBase):
    '''
    Name: test_detailed_view
    Steps:
        Create new User via SignUp request-->Login with This One-->
         build "activationUrl"-->
        Validation of successful activate-->
        close Wizard --> Logout-->login-->Open Wizard--> fill all fields
         in all Tab's(4)-->
        build inviteURL from email--> reopen browser with inviteURL-->
        Validate fields filled's in SignUp form
    '''

    user_content = None

    @classmethod
    def setUpClass(cls):
        super(TestDetailedView, cls).setUpClass()
        cls.user_content = API.VirtualFunction.create_engagement(
            wait_for_gitlab=False)

    @exception()
    def test_detailed_view(self):
        Frontend.User.login(
            self.user_content['el_email'], Constants.Default.Password.TEXT)
        Frontend.DetailedView.search_vf_and_go_to_detailed_view(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        Frontend.DetailedView.validate_all_titles_on_dv_form()
        logger.debug("Add Deployment Target")
        Frontend.DetailedView.add_deployment_target(self.user_content)
        logger.debug("Add VFC no.1")
        Frontend.DetailedView.add_vfcs("djoni", "loka")
        Frontend.DetailedView.remove_vfc(self.user_content)

    @exception()
    def test_update_aic_version(self):
        Frontend.User.login(
            self.user_content['email'], Constants.Default.Password.TEXT)
        Frontend.DetailedView.search_vf_and_go_to_detailed_view(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        Frontend.DetailedView.update_aic_version()
        Frontend.DetailedView.validate_aic_version()

    @exception()
    def test_update_vf_version(self):
        Frontend.User.login(
            self.user_content['email'], Constants.Default.Password.TEXT)
        Frontend.DetailedView.search_vf_and_go_to_detailed_view(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        newVFVersionName = Frontend.DetailedView.update_vf_version()
        Frontend.DetailedView.validate_vf_version(newVFVersionName)

    '''
    Add new ECOMP release to DB, go to detailed view and change
    ECOMP release and AIC version.
    Verify changes are saved and presented in UI.
    '''
    @exception()
    def test_edit_ecomp_release(self):
        try:
            EcompUuid = uuid.uuid4()
            EcompName = Helper.rand_string("randomString")
            DB.VirtualFunction.insert_ecomp_release(EcompUuid, EcompName)
            Frontend.User.login(
                self.user_content['email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.update_ecomp_release(EcompName)
            Frontend.DetailedView.validate_ecomp_version()
        finally:
            DB.VirtualFunction.delete_ecomp_release(EcompUuid, EcompName)

    @exception()
    def test_role_for_deployment_targets(self):
        users = [self.user_content['pr_email'],
                 self.user_content['el_email'], Constants.Users.Admin.EMAIL]
        Frontend.DetailedView.validate_deployment_targets(
            self.user_content, users)

    @exception()
    def test_add_and_remove_deployment_targets(self):
        users = [self.user_content['el_email'], Constants.Users.Admin.EMAIL]
        Frontend.DetailedView.add_remove_deployment_targets(
            self.user_content, users)

    @exception()
    def test_negative_role_for_deployment_targets(self):
        users = [self.user_content['email'], Constants.Users.AdminRO.EMAIL]
        Frontend.DetailedView.validate_negative_role_for_deployment_targets(
            self.user_content, users)

    @exception()
    def test_change_target_lab_entry(self):
        Frontend.User.login(Constants.Users.Admin.EMAIL,
                            Constants.Default.Password.TEXT)
        Frontend.DetailedView.search_vf_and_go_to_detailed_view(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        date = Frontend.DetailedView.update_target_lab_entry()
        Frontend.DetailedView.validate_target_lab_entry(date)

    @exception()
    def test_change_target_lab_entry_via_standard_user(self):
        Frontend.User.login(
            self.user_content['email'], Constants.Default.Password.TEXT)
        Frontend.DetailedView.search_vf_and_go_to_detailed_view(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        date = Frontend.DetailedView.update_target_lab_entry()
        Frontend.DetailedView.validate_target_lab_entry(date)

    @exception()
    def test_aic_dropdown_ordering(self):
        new_aic_version = None
        try:
            DB.VirtualFunction.change_aic_version_weight(10, 0)
            new_aic_version = DB.VirtualFunction.insert_aic_version()
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.click_on_update_aic_version()
            Helper.internal_assert(
                Frontend.General.
                get_meta_order_of_element(Constants.Dashboard.DetailedView.AIC.
                                          Dropdown.UniversalVersion.ID %
                                          new_aic_version['version']), 0)
        finally:
            if new_aic_version:
                DB.VirtualFunction.delete_aic_version(new_aic_version['uuid'])
            DB.VirtualFunction.change_aic_version_weight(0, 10)

    @exception()
    def test_ecomp_dropdown_ordering(self):
        new_ecomp_release = None
        try:
            new_ecomp_release = {
                "uuid": uuid.uuid4(), "name": Helper.rand_string()}
            DB.VirtualFunction.change_ecomp_release_weight(10, 0)
            DB.VirtualFunction.insert_ecomp_release(
                new_ecomp_release['uuid'], new_ecomp_release['name'])
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.click_on_update_ecomp_release()
            Helper.internal_assert(
                Frontend.General.get_meta_order_of_element(
                    Constants.Dashboard.DetailedView.ECOMP.Dropdown.
                    UniversalRelease.ID %
                    new_ecomp_release['name']), 0)
        finally:
            if new_ecomp_release:
                DB.VirtualFunction.delete_ecomp_release(
                    new_ecomp_release['uuid'], new_ecomp_release['name'])
            DB.VirtualFunction.change_ecomp_release_weight(0, 10)

    @exception()
    def test_retire_aic_version(self):
        new_aic_version = None
        try:
            new_aic_version = DB.VirtualFunction.insert_aic_version("FALSE")
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.click_on_update_aic_version()
            session.run_negative(
                lambda: Frontend.General.get_meta_order_of_element(
                    Constants.Dashboard.DetailedView.AIC.Dropdown.
                    UniversalVersion.ID %
                    new_aic_version['version']),
                "New AIC version was found in dropdown.")
        finally:
            if new_aic_version:
                DB.VirtualFunction.delete_aic_version(new_aic_version['uuid'])

    @exception()
    def test_retire_ecomp_release(self):
        new_ecomp_release = None
        try:
            new_ecomp_release = {
                "uuid": uuid.uuid4(),
                "name": Helper.rand_string(),
                "ui_visibility": "FALSE"}
            DB.VirtualFunction.insert_ecomp_release(
                new_ecomp_release['uuid'],
                new_ecomp_release['name'],
                new_ecomp_release['ui_visibility'])
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.click_on_update_ecomp_release()
            session.run_negative(
                lambda: Frontend.General.get_meta_order_of_element(
                    Constants.Dashboard.DetailedView.ECOMP.Dropdown.
                    UniversalRelease.ID %
                    new_ecomp_release['name']),
                "New ECOMP release was found in dropdown.")
        finally:
            if new_ecomp_release:
                DB.VirtualFunction.delete_ecomp_release(
                    new_ecomp_release['uuid'], new_ecomp_release['name'])

    @exception()
    def test_retire_selected_aic_version(self):
        old_aic_version_uuid = new_aic_version = None
        try:
            old_aic_version_uuid = DB.VirtualFunction.select_aic_version_uuid(
                self.user_content['target_aic'])
            new_aic_version = DB.VirtualFunction.insert_aic_version("FALSE")
            self.user_content['session_token'] = "token " + \
                API.User.login_user(self.user_content['el_email'])
            API.VirtualFunction.update_aic_version(
                self.user_content['engagement_uuid'],
                new_aic_version['uuid'],
                self.user_content['session_token'])
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.compare_aic_selected_version(
                new_aic_version['version'])
            Frontend.DetailedView.click_on_update_aic_version()
            Frontend.DetailedView.validate_deprecated_aic_version_in_dropdown(
                new_aic_version['version'])
        finally:
            if old_aic_version_uuid:
                API.VirtualFunction.update_aic_version(
                    self.user_content['engagement_uuid'],
                    old_aic_version_uuid,
                    self.user_content['session_token'])
                if new_aic_version:
                    DB.VirtualFunction.delete_aic_version(
                        new_aic_version['uuid'])

    @exception()
    def test_retire_selected_ecomp_release(self):
        old_ecomp_release_uuid = new_ecomp_release = None
        try:
            old_ecomp_release_uuid = \
                DB.VirtualFunction.select_ecomp_release_uuid(
                    self.user_content['ecomp_release'])
            new_ecomp_release = {
                "uuid": str(
                    uuid.uuid4()),
                "name": Helper.rand_string(),
                "ui_visibility": "FALSE"}
            DB.VirtualFunction.insert_ecomp_release(
                new_ecomp_release['uuid'],
                new_ecomp_release['name'],
                new_ecomp_release['ui_visibility'])
            self.user_content['session_token'] = "token " + \
                API.User.login_user(self.user_content['el_email'])
            API.VirtualFunction.update_ecomp_release(
                self.user_content['engagement_uuid'],
                new_ecomp_release['uuid'],
                self.user_content['session_token'])
            Frontend.User.login(
                self.user_content['el_email'], Constants.Default.Password.TEXT)
            Frontend.DetailedView.search_vf_and_go_to_detailed_view(
                self.user_content['engagement_manual_id'],
                self.user_content['vfName'])
            Frontend.DetailedView.compare_selected_ecomp_release(
                new_ecomp_release['name'])
            Frontend.DetailedView.click_on_update_ecomp_release()
            Frontend.DetailedView.\
                validate_deprecated_ecomp_release_in_dropdown(
                    new_ecomp_release['name'])
        finally:
            if self.user_content and old_ecomp_release_uuid:
                API.VirtualFunction.update_ecomp_release(
                    self.user_content['engagement_uuid'],
                    old_ecomp_release_uuid,
                    self.user_content['session_token'])
                DB.VirtualFunction.delete_ecomp_release(
                    new_ecomp_release['uuid'], new_ecomp_release['name'])