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