Skip to content

Commit

Permalink
Updated imports in e2e_tests/test_objects.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Chernevskiy committed Sep 15, 2022
1 parent bf99a21 commit 07fc542
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions e2e_tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import unittest

from e2e_tests.connector_facade import E2EConnectorFacade
from infoblox_client.objects import ARecord, DNSZone, AAAARecord, Network, \
EADefinition, EA, HostRecord, IP
from infoblox_client import objects


class TestObjectsE2E(unittest.TestCase):
Expand All @@ -22,19 +21,19 @@ def tearDown(self):
def test_create_alias_a_record(self):
"""Create two A records with different names, but pointing to the same
ipv4addr"""
DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")

alias1, created = ARecord.create_check_exists(
alias1, created = objects.ARecord.create_check_exists(
self.connector,
view='default',
ipv4addr="192.168.1.25",
name='alias1.e2e-test.com',
)
self.assertTrue(created)

alias2, created = ARecord.create_check_exists(
alias2, created = objects.ARecord.create_check_exists(
self.connector,
view='default',
ipv4addr="192.168.1.25",
Expand All @@ -46,19 +45,19 @@ def test_create_alias_a_record(self):
def test_create_alias_aaaa_record(self):
"""Create two AAAA records with different names, but pointing to the
same ipv6addr"""
DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")

alias1, created = AAAARecord.create_check_exists(
alias1, created = objects.AAAARecord.create_check_exists(
self.connector,
view='default',
ipv6addr="aaaa:bbbb:cccc:dddd::",
name='alias1.e2e-test.com',
)
self.assertTrue(created)

alias2, created = AAAARecord.create_check_exists(
alias2, created = objects.AAAARecord.create_check_exists(
self.connector,
view='default',
ipv6addr="aaaa:bbbb:cccc:dddd::",
Expand All @@ -70,14 +69,20 @@ def test_create_alias_aaaa_record(self):
def test_create_object_check_response(self):
"""Objects returned by create method should contain response field"""
# When WAPI object is successfully created
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com')
zone = objects.DNSZone.create(self.connector,
view='default',
fqdn='check_response_zone.com')
self.assertEqual("Infoblox Object was Created", zone.response)
# When WAPI object already exists
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com')
zone = objects.DNSZone.create(self.connector,
view='default',
fqdn='check_response_zone.com')
self.assertEqual("Infoblox Object already Exists", zone.response)
# When WAPI object is updated
zone = DNSZone.create(self.connector, view='default', fqdn='check_response_zone.com',
comment="Zone updated", update_if_exists=True, ref=zone.ref)
zone = objects.DNSZone.create(self.connector, view='default',
fqdn='check_response_zone.com',
comment="Zone updated",
update_if_exists=True, ref=zone.ref)
self.assertEqual("Infoblox Object was Updated", zone.response)

def test_fetch_by_ref_when_paging_enabled(self):
Expand All @@ -87,11 +92,11 @@ def test_fetch_by_ref_when_paging_enabled(self):
"""
# Enable paging for the test connector
self.connector.paging = True
zone1 = DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
zone1 = objects.DNSZone.create(self.connector,
view='default',
fqdn="e2e-test.com")
# Fetch DNS zone by ref
zone2 = DNSZone(self.connector)
zone2 = objects.DNSZone(self.connector)
zone2._ref = zone1._ref
zone2.fetch()
self.assertEqual(zone1.fqdn, zone2.fqdn)
Expand All @@ -103,9 +108,10 @@ def test_update_dns_zone(self):
Related ticket: NIOS-84427
"""
# Create DNS Zone
zone = DNSZone.create(self.connector,
fqdn="e2e-test-zone.com",
view="default")
zone = objects.DNSZone.create(self.connector,
fqdn="e2e-test-zone.com",
view="default",
check_if_exists=False)
# Update DNS zone
zone.Comment = "Modified"
zone.update()
Expand All @@ -116,51 +122,51 @@ def test_host_record_ea_inheritance(self):
works as expected
"""
# Create inheritable extensible attribute
EADefinition.create(
objects.EADefinition.create(
self.connector,
name="Test HostRecord EA Inheritance",
type="STRING",
flags="I",
)
# Create two networks with inheritable
# extensible attributes
Network.create(
objects.Network.create(
self.connector,
network="192.170.1.0/24",
network_view="default",
extattrs=EA({
extattrs=objects.EA({
"Test HostRecord EA Inheritance": "Expected Value"
})
)
Network.create(
objects.Network.create(
self.connector,
network="192.180.1.0/24",
network_view="default",
extattrs=EA({
extattrs=objects.EA({
"Test HostRecord EA Inheritance": "Second Value"
})
)

# Create DNS Zone for the host record
DNSZone.create(
objects.DNSZone.create(
self.connector,
view='default',
fqdn="e2e-test.com",
)

# Create two ips in both networks
# One IP will be used for EA inheritance
ip170net = IP.create(
ip170net = objects.IP.create(
ip="192.170.1.25",
mac="00:00:00:00:00:00",
use_for_ea_inheritance=True,
)
ip180net = IP.create(
ip180net = objects.IP.create(
ip="192.180.1.25",
mac="00:00:00:00:00:00",
)

hr = HostRecord.create(
hr = objects.HostRecord.create(
self.connector,
view="default",
name="test_host_record_ea_inheritance.e2e-test.com",
Expand Down

0 comments on commit 07fc542

Please sign in to comment.