blob: ff164fa2c76aaa28aa74f283ce1036d8ff92c336 [file] [log] [blame]
Adam Israel6d84dbd2019-03-08 18:33:35 -05001"""
2Test N2VC's ssh key generation
3"""
4import n2vc
Adam Israel6d84dbd2019-03-08 18:33:35 -05005import pytest
6from . import base
Adam Israel6d84dbd2019-03-08 18:33:35 -05007import uuid
8
9
10@pytest.mark.asyncio
11async 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
25async 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
41async 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())