blob: 543251684de3c4a6dc6252013fef61eff8296eee [file] [log] [blame]
Mike Marchetti08f04282017-05-04 16:43:09 -04001# Copyright 2017 Sandvine
2#
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import pytest
18import time
19
20
21@pytest.mark.vim
22@pytest.mark.openstack
kasar0e4186c2017-08-16 23:40:41 -070023@pytest.mark.vmware
Mike Marchetti08f04282017-05-04 16:43:09 -040024class TestClass(object):
25
26 def test_empty_vim(self,osm):
27 assert not osm.get_api().vim.list()
28
29 @pytest.fixture(scope='function')
30 def cleanup_test_add_vim_account(self,osm,request):
31 def teardown():
32 try:
33 osm.get_api().vim.delete('pytest')
34 except:
35 pass
36 request.addfinalizer(teardown)
37
38 @pytest.mark.openstack
39 def test_add_vim_account(self,osm,openstack,cleanup_test_add_vim_account):
40 os_access=openstack.get_access()
41 assert not osm.get_api().vim.create('pytest',os_access)
42
43 resp=osm.get_api().vim.get('pytest')
44 assert resp['name'] == 'pytest'
45 assert resp['type'] == 'openstack'
46 assert resp['vim_url'] == os_access['os-url']
47 assert resp['vim_url_admin'] == os_access['os-url']
48 assert resp['vim_tenants'][0]['user'] == os_access['os-username']
49 assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['os-project-name']
50
51 assert not osm.get_api().vim.delete('pytest')
kasar0e4186c2017-08-16 23:40:41 -070052
53 @pytest.mark.vmware
54 def test_add_vim_account_vmware(self,osm,vmware,cleanup_test_add_vim_account):
55 os_access=vmware.get_access()
56 assert not osm.get_api().vim.create('pytest',os_access)
57
58 resp=osm.get_api().vim.get('pytest')
59 assert resp['name'] == 'pytest'
60 assert resp['type'] == 'vmware'
61 assert resp['vim_url'] == os_access['vcd-url']
62 assert resp['vim_url_admin'] == os_access['vcd-url']
63 assert resp['vim_tenants'][0]['user'] == os_access['vcd-username']
64 assert resp['vim_tenants'][0]['vim_tenant_name'] == os_access['vcd-tenant-name']
65
66 assert not osm.get_api().vim.delete('pytest')