~lutostag/ubuntu/utopic/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/provisioningserver/dhcp/tests/test_detect.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Graham Binns, Andres Rodriguez, Julian Edwards, Seth Arnold
  • Date: 2014-02-15 12:08:23 UTC
  • mfrom: (1.2.22)
  • Revision ID: package-import@ubuntu.com-20140215120823-kew2lqrw5qgww721
Tags: 1.5+bzr1948-0ubuntu1
* New upstream release.

[ Graham Binns ]
* debian/control: Depends on python-jsonschema.

[ Andres Rodriguez ]
* debian/maas-region-controller-min.posinst: Make txlongpoll.yaml only
  readable by the app and not world readeable.
* debian/patches/02-pserv-config.patch: Refreshed.

[ Julian Edwards ]
* debian/extras/maas-cli renamed to debian/extras/maas, and introduce
  a deprecation warning in favour of using maas over maas-cli.
* debian/extras/maas renamed to debian/extras/maas-region-admin
* debian/maas-cli.install: install debian/extras/maas
* debian/maas-dns.postinst: Invoke maas-region-admin instead of maas
* debian/maas-region-controller-min.install: install maas-region-admin
  instead of maas
* debian/maas-region-controller.postinst: Invoke maas-region-admin instead
  of maas
* debian/maas-cli.links: Link from maas to maas-cli for backward compat.

[ Seth Arnold ]
* debian/maas-region-controller-min.postinst: Make sure txlongpoll.yaml
  gets correct permissions on upgrade (LP: #1254034)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2013 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2013-2014 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Tests for dhcp/detect.py"""
467
467
        mocked_logging.assert_called_once()
468
468
 
469
469
    def test_update_region_controller_sets_detected_dhcp(self):
470
 
        mocked_put = self.patch(MAASClient, 'put')
471
 
        mocked_put.return_value = MockResponse()
 
470
        mocked_post = self.patch(MAASClient, 'post')
 
471
        mocked_post.return_value = MockResponse()
472
472
        detected_server = factory.getRandomIPAddress()
473
473
        update_region_controller(self.knowledge, "eth0", detected_server)
474
 
        mocked_put.assert_called_once_with(
 
474
        mocked_post.assert_called_once_with(
475
475
            'api/1.0/nodegroups/%s/interfaces/eth0/' % self.knowledge[
476
476
                'nodegroup_uuid'],
477
 
            foreign_dhcp_ip=detected_server)
 
477
            'report_foreign_dhcp', foreign_dhcp_ip=detected_server)
478
478
 
479
479
    def test_update_region_controller_clears_detected_dhcp(self):
480
 
        mocked_put = self.patch(MAASClient, 'put')
481
 
        mocked_put.return_value = MockResponse()
 
480
        mocked_post = self.patch(MAASClient, 'post')
 
481
        mocked_post.return_value = MockResponse()
482
482
        detected_server = None
483
483
        update_region_controller(self.knowledge, "eth0", detected_server)
484
 
        mocked_put.assert_called_once_with(
 
484
        mocked_post.assert_called_once_with(
485
485
            'api/1.0/nodegroups/%s/interfaces/eth0/' % self.knowledge[
486
486
                'nodegroup_uuid'],
487
 
            foreign_dhcp_ip='')
 
487
            'report_foreign_dhcp', foreign_dhcp_ip='')
488
488
 
489
489
    def test_update_region_controller_catches_HTTPError_in_MAASClient(self):
490
 
        self.patch(MAASClient, 'put').side_effect = urllib2.HTTPError(
 
490
        self.patch(MAASClient, 'post').side_effect = urllib2.HTTPError(
491
491
            mock.sentinel, mock.sentinel, mock.sentinel,
492
492
            mock.sentinel, mock.sentinel)
493
493
        mocked_logging = self.patch(detect_module.logger, 'error')
495
495
        mocked_logging.assert_called_once()
496
496
 
497
497
    def test_update_region_controller_catches_URLError_in_MAASClient(self):
498
 
        self.patch(MAASClient, 'put').side_effect = urllib2.URLError(
 
498
        self.patch(MAASClient, 'post').side_effect = urllib2.URLError(
499
499
            mock.sentinel.arg1)
500
500
        mocked_logging = self.patch(detect_module.logger, 'error')
501
501
        update_region_controller(self.knowledge, "eth0", None)
503
503
 
504
504
    def test_update_region_controller_catches_non_OK_response(self):
505
505
        mock_response = MockResponse(httplib.NOT_FOUND, "error text")
506
 
        self.patch(MAASClient, 'put').return_value = mock_response
 
506
        self.patch(MAASClient, 'post').return_value = mock_response
507
507
        mocked_logging = self.patch(detect_module.logger, 'error')
508
508
        update_region_controller(self.knowledge, "eth0", None)
509
509
        mocked_logging.assert_called_once_with(