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
Justin Riley 2016-08-03 00:35:58 -04:00
parent eff941dbf8
commit 679f3a0369
4 changed files with 20 additions and 1 deletions

View File

@ -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',
)

View File

@ -17,6 +17,9 @@ def dns(request):
return dns
@pytest.fixture(scope="module")
@pytest.fixture(scope="function")
def oneclient(request):
"""
NOTE: All fixtures must be function scope to work with VCRPY cassettes
"""
return one.OneClient()

View File

@ -1,15 +1,19 @@
from onedns.tests import vcr
import pytest
import oca
from oca import vm
@vcr.use_cassette()
def test_get_vms(oneclient):
vms = oneclient.vms()
assert isinstance(vms, vm.VirtualMachinePool)
assert len(vms) > 0
@vcr.use_cassette()
def test_get_vm_by_id(oneclient):
with pytest.raises(TypeError):
oneclient.get_vm_by_id('asdf')

View File

@ -29,6 +29,7 @@ setup(
tests_require=[
"pytest>=2.9.2",
"testfixtures>=4.10.0",
"vcrpy>=1.9.0",
],
entry_points=dict(console_scripts=['onedns = onedns.cli:main']),
zip_safe=False