summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/networks/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/networks/tests.py')
-rw-r--r--openstack_dashboard/dashboards/project/networks/tests.py85
1 files changed, 80 insertions, 5 deletions
diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py
index ac097fe..bd2c860 100644
--- a/openstack_dashboard/dashboards/project/networks/tests.py
+++ b/openstack_dashboard/dashboards/project/networks/tests.py
@@ -363,6 +363,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
363 'subnetpool_list')}) 363 'subnetpool_list')})
364 def test_network_create_get(self): 364 def test_network_create_get(self):
365 api.neutron.is_extension_supported(IsA(http.HttpRequest), 365 api.neutron.is_extension_supported(IsA(http.HttpRequest),
366 'network_availability_zone').\
367 AndReturn(False)
368 api.neutron.is_extension_supported(IsA(http.HttpRequest),
366 'subnet_allocation').\ 369 'subnet_allocation').\
367 AndReturn(True) 370 AndReturn(True)
368 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 371 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -389,6 +392,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
389 'admin_state_up': network.admin_state_up, 392 'admin_state_up': network.admin_state_up,
390 'shared': False} 393 'shared': False}
391 api.neutron.is_extension_supported(IsA(http.HttpRequest), 394 api.neutron.is_extension_supported(IsA(http.HttpRequest),
395 'network_availability_zone').\
396 AndReturn(False)
397 api.neutron.is_extension_supported(IsA(http.HttpRequest),
392 'subnet_allocation').\ 398 'subnet_allocation').\
393 AndReturn(True) 399 AndReturn(True)
394 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 400 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -411,6 +417,43 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
411 417
412 @test.create_stubs({api.neutron: ('network_create', 418 @test.create_stubs({api.neutron: ('network_create',
413 'is_extension_supported', 419 'is_extension_supported',
420 'list_availability_zones',
421 'subnetpool_list')})
422 def test_network_create_post_with_az(self):
423 network = self.networks.first()
424 params = {'name': network.name,
425 'admin_state_up': network.admin_state_up,
426 'shared': False,
427 'az_hints': ['nova']}
428 api.neutron.is_extension_supported(IsA(http.HttpRequest),
429 'network_availability_zone').\
430 AndReturn(True)
431 api.neutron.list_availability_zones(IsA(http.HttpRequest),
432 "network", "available")\
433 .AndReturn(self.neutron_availability_zones.list())
434 api.neutron.is_extension_supported(IsA(http.HttpRequest),
435 'subnet_allocation').\
436 AndReturn(True)
437 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
438 AndReturn(self.subnetpools.list())
439 api.neutron.network_create(IsA(http.HttpRequest),
440 **params).AndReturn(network)
441 self.mox.ReplayAll()
442
443 form_data = {'net_name': network.name,
444 'admin_state': network.admin_state_up,
445 'shared': False,
446 'with_subnet': False,
447 'availability_zone_hints': ['nova']}
448 form_data.update(form_data_no_subnet())
449 url = reverse('horizon:project:networks:create')
450 res = self.client.post(url, form_data)
451
452 self.assertNoFormErrors(res)
453 self.assertRedirectsNoFollow(res, INDEX_URL)
454
455 @test.create_stubs({api.neutron: ('network_create',
456 'is_extension_supported',
414 'subnetpool_list')}) 457 'subnetpool_list')})
415 def test_network_create_post_with_shared(self): 458 def test_network_create_post_with_shared(self):
416 network = self.networks.first() 459 network = self.networks.first()
@@ -418,6 +461,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
418 'admin_state_up': network.admin_state_up, 461 'admin_state_up': network.admin_state_up,
419 'shared': True} 462 'shared': True}
420 api.neutron.is_extension_supported(IsA(http.HttpRequest), 463 api.neutron.is_extension_supported(IsA(http.HttpRequest),
464 'network_availability_zone').\
465 AndReturn(False)
466 api.neutron.is_extension_supported(IsA(http.HttpRequest),
421 'subnet_allocation').\ 467 'subnet_allocation').\
422 AndReturn(True) 468 AndReturn(True)
423 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 469 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -459,6 +505,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
459 subnet.ip_version = 4 505 subnet.ip_version = 4
460 subnet_params['ip_version'] = subnet.ip_version 506 subnet_params['ip_version'] = subnet.ip_version
461 api.neutron.is_extension_supported(IsA(http.HttpRequest), 507 api.neutron.is_extension_supported(IsA(http.HttpRequest),
508 'network_availability_zone').\
509 AndReturn(False)
510 api.neutron.is_extension_supported(IsA(http.HttpRequest),
462 'subnet_allocation').\ 511 'subnet_allocation').\
463 AndReturn(True) 512 AndReturn(True)
464 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 513 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -493,6 +542,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
493 'shared': False, 542 'shared': False,
494 'admin_state_up': network.admin_state_up} 543 'admin_state_up': network.admin_state_up}
495 api.neutron.is_extension_supported(IsA(http.HttpRequest), 544 api.neutron.is_extension_supported(IsA(http.HttpRequest),
545 'network_availability_zone').\
546 AndReturn(False)
547 api.neutron.is_extension_supported(IsA(http.HttpRequest),
496 'subnet_allocation').\ 548 'subnet_allocation').\
497 AndReturn(True) 549 AndReturn(True)
498 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 550 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -516,16 +568,16 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
516 @test.create_stubs({api.neutron: ('network_create', 568 @test.create_stubs({api.neutron: ('network_create',
517 'is_extension_supported', 569 'is_extension_supported',
518 'subnetpool_list')}) 570 'subnetpool_list')})
519 def test_network_create_post_with_subnet_network_exception( 571 def test_network_create_post_with_subnet_network_exception(self):
520 self,
521 test_with_subnetpool=False,
522 ):
523 network = self.networks.first() 572 network = self.networks.first()
524 subnet = self.subnets.first() 573 subnet = self.subnets.first()
525 params = {'name': network.name, 574 params = {'name': network.name,
526 'shared': False, 575 'shared': False,
527 'admin_state_up': network.admin_state_up} 576 'admin_state_up': network.admin_state_up}
528 api.neutron.is_extension_supported(IsA(http.HttpRequest), 577 api.neutron.is_extension_supported(IsA(http.HttpRequest),
578 'network_availability_zone').\
579 AndReturn(False)
580 api.neutron.is_extension_supported(IsA(http.HttpRequest),
529 'subnet_allocation').\ 581 'subnet_allocation').\
530 AndReturn(True) 582 AndReturn(True)
531 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 583 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -557,6 +609,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
557 'shared': False, 609 'shared': False,
558 'admin_state_up': network.admin_state_up} 610 'admin_state_up': network.admin_state_up}
559 api.neutron.is_extension_supported(IsA(http.HttpRequest), 611 api.neutron.is_extension_supported(IsA(http.HttpRequest),
612 'network_availability_zone').\
613 AndReturn(False)
614 api.neutron.is_extension_supported(IsA(http.HttpRequest),
560 'subnet_allocation').\ 615 'subnet_allocation').\
561 AndReturn(True) 616 AndReturn(True)
562 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 617 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -593,6 +648,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
593 network = self.networks.first() 648 network = self.networks.first()
594 subnet = self.subnets.first() 649 subnet = self.subnets.first()
595 api.neutron.is_extension_supported(IsA(http.HttpRequest), 650 api.neutron.is_extension_supported(IsA(http.HttpRequest),
651 'network_availability_zone').\
652 AndReturn(False)
653 api.neutron.is_extension_supported(IsA(http.HttpRequest),
596 'subnet_allocation').\ 654 'subnet_allocation').\
597 AndReturn(True) 655 AndReturn(True)
598 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 656 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -628,6 +686,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
628 network = self.networks.first() 686 network = self.networks.first()
629 subnet = self.subnets.first() 687 subnet = self.subnets.first()
630 api.neutron.is_extension_supported(IsA(http.HttpRequest), 688 api.neutron.is_extension_supported(IsA(http.HttpRequest),
689 'network_availability_zone').\
690 AndReturn(False)
691 api.neutron.is_extension_supported(IsA(http.HttpRequest),
631 'subnet_allocation').\ 692 'subnet_allocation').\
632 AndReturn(True) 693 AndReturn(True)
633 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 694 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -666,6 +727,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
666 subnet = self.subnets.first() 727 subnet = self.subnets.first()
667 728
668 api.neutron.is_extension_supported(IsA(http.HttpRequest), 729 api.neutron.is_extension_supported(IsA(http.HttpRequest),
730 'network_availability_zone').\
731 AndReturn(False)
732 api.neutron.is_extension_supported(IsA(http.HttpRequest),
669 'subnet_allocation').\ 733 'subnet_allocation').\
670 AndReturn(True) 734 AndReturn(True)
671 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 735 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -708,6 +772,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
708 subnet_v6 = self.subnets.list()[4] 772 subnet_v6 = self.subnets.list()[4]
709 773
710 api.neutron.is_extension_supported(IsA(http.HttpRequest), 774 api.neutron.is_extension_supported(IsA(http.HttpRequest),
775 'network_availability_zone').\
776 AndReturn(False)
777 api.neutron.is_extension_supported(IsA(http.HttpRequest),
711 'subnet_allocation').\ 778 'subnet_allocation').\
712 AndReturn(True) 779 AndReturn(True)
713 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 780 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -758,6 +825,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
758 'enable_dhcp': subnet.enable_dhcp} 825 'enable_dhcp': subnet.enable_dhcp}
759 826
760 api.neutron.is_extension_supported(IsA(http.HttpRequest), 827 api.neutron.is_extension_supported(IsA(http.HttpRequest),
828 'network_availability_zone').\
829 AndReturn(False)
830 api.neutron.is_extension_supported(IsA(http.HttpRequest),
761 'subnet_allocation').\ 831 'subnet_allocation').\
762 AndReturn(True) 832 AndReturn(True)
763 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 833 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -792,6 +862,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
792 subnet = self.subnets.first() 862 subnet = self.subnets.first()
793 863
794 api.neutron.is_extension_supported(IsA(http.HttpRequest), 864 api.neutron.is_extension_supported(IsA(http.HttpRequest),
865 'network_availability_zone').\
866 AndReturn(False)
867 api.neutron.is_extension_supported(IsA(http.HttpRequest),
795 'subnet_allocation').\ 868 'subnet_allocation').\
796 AndReturn(True) 869 AndReturn(True)
797 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\ 870 api.neutron.subnetpool_list(IsA(http.HttpRequest)).\
@@ -828,7 +901,9 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
828 ): 901 ):
829 network = self.networks.first() 902 network = self.networks.first()
830 subnet = self.subnets.first() 903 subnet = self.subnets.first()
831 904 api.neutron.is_extension_supported(IsA(http.HttpRequest),
905 'network_availability_zone').\
906 AndReturn(False)
832 api.neutron.is_extension_supported(IsA(http.HttpRequest), 907 api.neutron.is_extension_supported(IsA(http.HttpRequest),
833 'subnet_allocation').\ 908 'subnet_allocation').\
834 AndReturn(True) 909 AndReturn(True)