Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
If we requests that networks be allocated into the reserved states
through the next_network and next_address actions, then they
should be part of the results when the command
nsot networks list -c 10.2.1.0/24 reserved
  • Loading branch information
rmhasan committed Feb 6, 2017
1 parent 618f506 commit 4f11680
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/api_tests/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def test_get_next_detail_routes(site, client):
)


def test_next_network_reserve(site, client):
def test_next_network_allocation(site, client):
net_uri = site.list_uri('network')

client.create(net_uri, cidr='10.1.2.0/24')
Expand All @@ -679,11 +679,16 @@ def test_next_network_reserve(site, client):

uri = reverse('network-next-network', args=(site.id, net_24['id']))

client.post(uri, params={u'prefix_length': u'32', u'reserve': u'True'})
client.post(uri, params={u'prefix_length': u'32'})
assert_success(client.retrieve(uri, prefix_length=32), [u'10.1.2.2/32'])

client.post(uri, params={u'prefix_length': u'32', u'reserve': u'True'})

uri = reverse('network-reserved', args=(site.id,))
assert get_result(client.retrieve(uri))[0]['network_address'] == u'10.1.2.2'


def test_next_address_reserve(site, client):
def test_next_address_allocation(site, client):
net_uri = site.list_uri('network')

client.create(net_uri, cidr='10.1.2.0/24')
Expand All @@ -694,9 +699,14 @@ def test_next_address_reserve(site, client):

uri = reverse('network-next-address', args=(site.id, net_24['id']))

client.post(uri, params={u'reserve': u'True'})
client.post(uri)
assert_success(client.retrieve(uri, prefix_length=32), [u'10.1.2.2/32'])

client.post(uri, params={u'reserve': u'True'})

uri = reverse('network-reserved', args=(site.id,))
assert get_result(client.retrieve(uri))[0]['network_address'] == u'10.1.2.2'


def test_reservation_list_route(site, client):
"""Test the list route for getting reserved networks/addresses."""
Expand Down

0 comments on commit 4f11680

Please sign in to comment.