Skip to content

Commit

Permalink
Also clean up / rest DigitalOcean mock http classes as part of tearDown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Apr 16, 2024
1 parent 6ba2819 commit f4fe2fb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libcloud/test/common/test_digitalocean_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from libcloud.test.secrets import DIGITALOCEAN_v2_PARAMS
from libcloud.test.file_fixtures import FileFixtures
from libcloud.common.digitalocean import DigitalOceanBaseDriver, DigitalOcean_v2_BaseDriver
from libcloud.dns.drivers.digitalocean import DigitalOceanDNSDriver


class DigitalOceanTests(LibcloudTestCase):
Expand All @@ -32,6 +31,10 @@ def setUp(self):
DigitalOceanCommonMockHttp.type = None
self.driver = DigitalOceanBaseDriver(*DIGITALOCEAN_v2_PARAMS)

def tearDown(self):
LibcloudConnection.type = None
DigitalOceanCommonMockHttp.type = None

def test_authentication(self):
DigitalOceanCommonMockHttp.type = "UNAUTHORIZED"
self.assertRaises(InvalidCredsError, self.driver.ex_account_info)
Expand Down
18 changes: 16 additions & 2 deletions libcloud/test/compute/test_digitalocean_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
from libcloud.test.secrets import DIGITALOCEAN_v1_PARAMS, DIGITALOCEAN_v2_PARAMS
from libcloud.utils.iso8601 import UTC
from libcloud.test.file_fixtures import ComputeFileFixtures
from libcloud.common.digitalocean import DigitalOcean_v1_Error
from libcloud.compute.drivers.digitalocean import DigitalOceanNodeDriver
from libcloud.common.digitalocean import (
DigitalOcean_v1_Error,
DigitalOceanBaseDriver,
DigitalOcean_v2_BaseDriver,
)
from libcloud.compute.drivers.digitalocean import (
DigitalOceanNodeDriver,
DigitalOcean_v2_NodeDriver,
)

try:
import simplejson as json
Expand All @@ -36,10 +43,17 @@
# class DigitalOceanTests(unittest.TestCase, TestCaseMixin):
class DigitalOcean_v2_Tests(LibcloudTestCase):
def setUp(self):
DigitalOceanBaseDriver.connectionCls.conn_class = DigitalOceanComputeMockHttp
DigitalOcean_v2_BaseDriver.connectionCls.conn_class = DigitalOceanComputeMockHttp
DigitalOceanNodeDriver.connectionCls.conn_class = DigitalOceanComputeMockHttp
DigitalOcean_v2_NodeDriver.connectionCls.conn_class = DigitalOceanComputeMockHttp
DigitalOceanComputeMockHttp.type = None
self.driver = DigitalOceanNodeDriver(*DIGITALOCEAN_v2_PARAMS)

def tearDown(self):
LibcloudConnection.type = None
DigitalOceanComputeMockHttp.type = None

def test_v1_Error(self):
self.assertRaises(
DigitalOcean_v1_Error,
Expand Down
7 changes: 7 additions & 0 deletions libcloud/test/dns/test_digitalocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@
from libcloud.utils.py3 import httplib
from libcloud.test.secrets import DIGITALOCEAN_v2_PARAMS
from libcloud.test.file_fixtures import DNSFileFixtures
from libcloud.common.digitalocean import DigitalOceanBaseDriver, DigitalOcean_v2_BaseDriver
from libcloud.dns.drivers.digitalocean import DigitalOceanDNSDriver


class DigitalOceanDNSTests(LibcloudTestCase):
def setUp(self):
DigitalOceanBaseDriver.connectionCls.conn_class = DigitalOceanDNSMockHttp
DigitalOcean_v2_BaseDriver.connectionCls.conn_class = DigitalOceanDNSMockHttp
DigitalOceanDNSDriver.connectionCls.conn_class = DigitalOceanDNSMockHttp
DigitalOceanDNSMockHttp.type = None
self.driver = DigitalOceanDNSDriver(*DIGITALOCEAN_v2_PARAMS)

def tearDown(self):
LibcloudConnection.type = None
DigitalOceanDNSMockHttp.type = None

def test_list_zones(self):
zones = self.driver.list_zones()
self.assertTrue(len(zones) >= 1)
Expand Down

0 comments on commit f4fe2fb

Please sign in to comment.