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