use vcrpy for oneclient tests
Will commit cassettes later once the tests have been executed on a test VM and the test authorization token has been stripped.master
parent
eff941dbf8
commit
679f3a0369
|
@ -0,0 +1,11 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from vcr import VCR
|
||||||
|
|
||||||
|
vcr = VCR(
|
||||||
|
serializer='yaml',
|
||||||
|
cassette_library_dir=os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)), 'fixtures/oneclient'
|
||||||
|
),
|
||||||
|
record_mode='once',
|
||||||
|
)
|
|
@ -17,6 +17,9 @@ def dns(request):
|
||||||
return dns
|
return dns
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="function")
|
||||||
def oneclient(request):
|
def oneclient(request):
|
||||||
|
"""
|
||||||
|
NOTE: All fixtures must be function scope to work with VCRPY cassettes
|
||||||
|
"""
|
||||||
return one.OneClient()
|
return one.OneClient()
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
|
from onedns.tests import vcr
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import oca
|
import oca
|
||||||
from oca import vm
|
from oca import vm
|
||||||
|
|
||||||
|
|
||||||
|
@vcr.use_cassette()
|
||||||
def test_get_vms(oneclient):
|
def test_get_vms(oneclient):
|
||||||
vms = oneclient.vms()
|
vms = oneclient.vms()
|
||||||
assert isinstance(vms, vm.VirtualMachinePool)
|
assert isinstance(vms, vm.VirtualMachinePool)
|
||||||
assert len(vms) > 0
|
assert len(vms) > 0
|
||||||
|
|
||||||
|
|
||||||
|
@vcr.use_cassette()
|
||||||
def test_get_vm_by_id(oneclient):
|
def test_get_vm_by_id(oneclient):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
oneclient.get_vm_by_id('asdf')
|
oneclient.get_vm_by_id('asdf')
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -29,6 +29,7 @@ setup(
|
||||||
tests_require=[
|
tests_require=[
|
||||||
"pytest>=2.9.2",
|
"pytest>=2.9.2",
|
||||||
"testfixtures>=4.10.0",
|
"testfixtures>=4.10.0",
|
||||||
|
"vcrpy>=1.9.0",
|
||||||
],
|
],
|
||||||
entry_points=dict(console_scripts=['onedns = onedns.cli:main']),
|
entry_points=dict(console_scripts=['onedns = onedns.cli:main']),
|
||||||
zip_safe=False
|
zip_safe=False
|
||||||
|
|
Loading…
Reference in New Issue