Skip to content

Commit

Permalink
Add a unit test which actually exercises #1650.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Mar 29, 2016
1 parent a1acc15 commit 247e293
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions gcloud/dns/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,42 @@ def test_quotas_defaults(self):
self.assertEqual(req['method'], 'GET')
self.assertEqual(req['path'], '/%s' % PATH)

def test_quotas_w_kind_key(self):
PROJECT = 'PROJECT'
PATH = 'projects/%s' % PROJECT
MANAGED_ZONES = 1234
RRS_PER_RRSET = 23
RRSETS_PER_ZONE = 345
RRSET_ADDITIONS = 456
RRSET_DELETIONS = 567
TOTAL_SIZE = 67890
DATA = {
'quota': {
'managedZones': str(MANAGED_ZONES),
'resourceRecordsPerRrset': str(RRS_PER_RRSET),
'rrsetsPerManagedZone': str(RRSETS_PER_ZONE),
'rrsetAdditionsPerChange': str(RRSET_ADDITIONS),
'rrsetDeletionsPerChange': str(RRSET_DELETIONS),
'totalRrdataSizePerChange': str(TOTAL_SIZE),
}
}
CONVERTED = dict([(key, int(value))
for key, value in DATA['quota'].items()])
WITH_KIND = {'quota': DATA['quota'].copy()}
WITH_KIND['quota']['kind'] = 'dns#quota'
creds = _Credentials()
client = self._makeOne(PROJECT, creds)
conn = client.connection = _Connection(WITH_KIND)

quotas = client.quotas()

self.assertEqual(quotas, CONVERTED)

self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
self.assertEqual(req['method'], 'GET')
self.assertEqual(req['path'], '/%s' % PATH)

def test_list_zones_defaults(self):
from gcloud.dns.zone import ManagedZone
PROJECT = 'PROJECT'
Expand Down

1 comment on commit 247e293

@ojengwa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Never would have thought of approaching testing this way... Seems like we are checking for the size of some returned attribute instead of the presence of the actual key/attribute.

Please sign in to comment.