1 # Copyright 2019 Canonical Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 Test N2VC's ssh key generation
25 async def test_model_create():
26 """Test the creation of a new model."""
27 client
= base
.get_n2vc()
29 model_name
= "test-{}".format(
30 uuid
.uuid4().hex[-4:],
33 pytest
.assume(await client
.CreateNetworkService(model_name
))
34 pytest
.assume(await client
.DestroyNetworkService(model_name
))
35 pytest
.assume(await client
.logout())
39 async def test_destroy_non_existing_network_service():
40 """Destroy a model that doesn't exist."""
42 client
= base
.get_n2vc()
44 model_name
= "test-{}".format(
45 uuid
.uuid4().hex[-4:],
48 with pytest
.raises(n2vc
.vnf
.NetworkServiceDoesNotExist
):
49 pytest
.assume(await client
.DestroyNetworkService(model_name
))
51 pytest
.assume(await client
.logout())
55 async def test_model_create_duplicate():
56 """Create a new model, and try to create the same model."""
57 client
= base
.get_n2vc()
59 model_name
= "test-{}".format(
60 uuid
.uuid4().hex[-4:],
63 # Try to recreate bug 628
64 for x
in range(0, 1000):
65 model
= await client
.get_model(model_name
)
68 pytest
.assume(await client
.DestroyNetworkService(model_name
))
69 pytest
.assume(await client
.logout())