Remove dependency on vendored libjuju
[osm/N2VC.git] / tests / test_model.py
1 """
2 Test N2VC's ssh key generation
3 """
4 import n2vc
5 import pytest
6 from . import base
7 import uuid
8
9
10 @pytest.mark.asyncio
11 async def test_model_create():
12 """Test the creation of a new model."""
13 client = base.get_n2vc()
14
15 model_name = "test-{}".format(
16 uuid.uuid4().hex[-4:],
17 )
18
19 pytest.assume(await client.CreateNetworkService(model_name))
20 pytest.assume(await client.DestroyNetworkService(model_name))
21 pytest.assume(await client.logout())
22
23
24 @pytest.mark.asyncio
25 async def test_destroy_non_existing_network_service():
26 """Destroy a model that doesn't exist."""
27
28 client = base.get_n2vc()
29
30 model_name = "test-{}".format(
31 uuid.uuid4().hex[-4:],
32 )
33
34 with pytest.raises(n2vc.vnf.NetworkServiceDoesNotExist):
35 pytest.assume(await client.DestroyNetworkService(model_name))
36
37 pytest.assume(await client.logout())
38
39
40 @pytest.mark.asyncio
41 async def test_model_create_duplicate():
42 """Create a new model, and try to create the same model."""
43 client = base.get_n2vc()
44
45 model_name = "test-{}".format(
46 uuid.uuid4().hex[-4:],
47 )
48
49 # Try to recreate bug 628
50 for x in range(0, 1000):
51 model = await client.get_model(model_name)
52 pytest.assume(model)
53
54 pytest.assume(await client.DestroyNetworkService(model_name))
55 pytest.assume(await client.logout())