From 56f6998753aaa71b20f1ba911e8de18e7ade6a0b Mon Sep 17 00:00:00 2001 From: Justin Riley Date: Fri, 12 Aug 2016 11:24:52 -0400 Subject: [PATCH] add vms fixture that gets recorded using vcrpy Should help prevent creating duplicate vcrpy yaml's in onedns/tests/fixtures for the same 'get all vms' request in multiple tests. --- onedns/tests/conftest.py | 7 +++++++ onedns/tests/test_oneclient.py | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/onedns/tests/conftest.py b/onedns/tests/conftest.py index b8693c4..6ee93b2 100644 --- a/onedns/tests/conftest.py +++ b/onedns/tests/conftest.py @@ -1,6 +1,7 @@ import pytest from onedns import resolver +from onedns.tests import vcr from onedns.clients import one @@ -23,3 +24,9 @@ def oneclient(request): NOTE: All fixtures must be function scope to work with VCRPY cassettes """ return one.OneClient() + + +@pytest.fixture(scope="function") +@vcr.use_cassette() +def vms(oneclient): + return oneclient.vms() diff --git a/onedns/tests/test_oneclient.py b/onedns/tests/test_oneclient.py index 9499cb8..9735071 100644 --- a/onedns/tests/test_oneclient.py +++ b/onedns/tests/test_oneclient.py @@ -6,9 +6,7 @@ import oca from oca import vm -@vcr.use_cassette() -def test_get_vms(oneclient): - vms = oneclient.vms() +def test_get_vms(vms): assert isinstance(vms, vm.VirtualMachinePool) assert len(vms) > 0