~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

Viewing changes to unit_tests/test_neutron_api_utils.py

  • Committer: James Page
  • Date: 2015-09-04 11:03:14 UTC
  • mfrom: (39.7.35 trunk)
  • Revision ID: james.page@ubuntu.com-20150904110314-1iym0vseisumy5d0
[project-calico,r=james-page] Add support for Calico plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    'apt_install',
25
25
    'apt_update',
26
26
    'apt_upgrade',
 
27
    'add_source',
27
28
    'b64encode',
28
29
    'config',
29
30
    'configure_installation_source',
34
35
    'pip_install',
35
36
    'subprocess',
36
37
    'is_elected_leader',
 
38
    'service_stop',
 
39
    'service_start',
 
40
    'glob',
37
41
]
38
42
 
39
43
openstack_origin_git = \
559
563
        self.test_config.set('manage-neutron-plugin-legacy-mode', False)
560
564
        manage = nutils.manage_plugin()
561
565
        self.assertFalse(manage)
 
566
 
 
567
    def test_additional_install_locations_calico(self):
 
568
        self.get_os_codename_install_source.return_value = 'icehouse'
 
569
        nutils.additional_install_locations('Calico', '')
 
570
        self.add_source.assert_called_with('ppa:project-calico/icehouse')
 
571
 
 
572
    def test_unusual_calico_install_location(self):
 
573
        self.test_config.set('calico-origin', 'ppa:testppa/project-calico')
 
574
        nutils.additional_install_locations('Calico', '')
 
575
        self.add_source.assert_called_with('ppa:testppa/project-calico')
 
576
 
 
577
    def test_follows_openstack_origin(self):
 
578
        self.get_os_codename_install_source.return_value = 'juno'
 
579
        nutils.additional_install_locations('Calico', 'cloud:trusty-juno')
 
580
        self.add_source.assert_called_with('ppa:project-calico/juno')
 
581
 
 
582
    @patch('shutil.rmtree')
 
583
    def test_force_etcd_restart(self, rmtree):
 
584
        self.glob.glob.return_value = [
 
585
            '/var/lib/etcd/one', '/var/lib/etcd/two'
 
586
        ]
 
587
        nutils.force_etcd_restart()
 
588
        self.service_stop.assert_called_once_with('etcd')
 
589
        self.glob.glob.assert_called_once_with('/var/lib/etcd/*')
 
590
        rmtree.assert_any_call('/var/lib/etcd/one')
 
591
        rmtree.assert_any_call('/var/lib/etcd/two')
 
592
        self.service_start.assert_called_once_with('etcd')