Esempio n. 1
0
    def test_state_go(self, jver, pyjuju_status):
        jver.side_effect = [JujuVersion(1, 11, 0, False)]
        mstatus = JujuStatus('juju')
        mstatus.add('test-charm')

        pyjuju_status.return_value = yaml.safe_load(str(mstatus))
        output = {'test-charm': {'0': 'started'}}
        self.assertEqual(output, waiter.state(juju_env='test'))
Esempio n. 2
0
    def test_jujuversion_malformed(self, mj):
        mj.return_value = '1.2.3.45'
        version = JujuVersion()

        self.assertEqual(version.major, 1)
        self.assertEqual(version.minor, 2)
        self.assertEqual(version.patch, 3)
        self.assertEqual(str(version), '1.2.3')

        mj.assert_called_once_with(['version'])
Esempio n. 3
0
    def test_jujuversion_go(self, mj):
        mj.side_effect = ['1.2.3-series-xxx']
        version = JujuVersion()

        self.assertEqual(version.major, 1)
        self.assertEqual(version.minor, 2)
        self.assertEqual(version.patch, 3)
        self.assertEqual(str(version), '1.2.3')

        mj.assert_called_with(['version'])
Esempio n. 4
0
    def test_jujuversion_py(self, mj):
        mj.side_effect = [OSError('Non-zero exit'), 'juju 8.6']
        version = JujuVersion()

        self.assertEqual(version.major, 8)
        self.assertEqual(version.minor, 6)
        self.assertEqual(version.patch, None)
        self.assertEqual(str(version), '8.6')

        mj.assert_called_with(['--version'])
Esempio n. 5
0
    def test_state_subordinate_removal(self, jver, ms):
        jver.side_effect = [JujuVersion(1, 17, 0, False)]
        mstatus = JujuStatus('juju')
        mstatus.add('test-sub')
        mstatus.add('test-srv')
        mstatus.status['services']['test-sub'].pop('units', None)
        mstatus.status['services']['test-sub']['subordinate-to'] = 'test-srv'

        ms.return_value = yaml.safe_load(str(mstatus))
        output = {'test-srv': {'0': 'started'}}
        self.assertEqual(output, waiter.state(juju_env='test'))
Esempio n. 6
0
    def test_state_specific_units(self, jver, pyjuju_status):
        jver.side_effect = [JujuVersion(0, 7, 0, False)]
        mstatus = JujuStatus('juju')
        mstatus.add('test-charm')
        mstatus.add('test-charm', state='pending')
        mstatus.add('test-charm')
        mstatus.add('test-charm-b')
        mstatus.add('test-charm-b')

        pyjuju_status.return_value = yaml.safe_load(str(mstatus))
        output = {'test-charm': {'1': 'pending'},
                  'test-charm-b': {'0': 'started', '1': 'started'}}
        self.assertEqual(output, waiter.state('test-charm/1', 'test-charm-b',
                                              juju_env='test'))
Esempio n. 7
0
    def test_status_no_juju_env(self, jver):
        jver.side_effect = [JujuVersion(0, 7, 0, False)]

        self.assertRaises(KeyError, waiter.state)
Esempio n. 8
0
    def test_status_error(self, jver, pyjuju_status):
        jver.side_effect = [JujuVersion(0, 7, 0, False)]

        pyjuju_status.side_effect = Exception
        self.assertEqual({}, waiter.state(juju_env='test'))
Esempio n. 9
0
    def test_state_timeout(self, jver, pyjuju_status):
        jver.side_effect = [JujuVersion(0, 7, 0, False)]

        pyjuju_status.side_effect = TimeoutError
        self.assertRaises(TimeoutError, waiter.state, juju_env='test')
Esempio n. 10
0
    def test_state_service_not_there(self, jver, pyjuju_status):
        jver.side_effect = [JujuVersion(0, 7, 0, False)]
        mstatus = JujuStatus('juju')

        pyjuju_status.return_value = yaml.safe_load(str(mstatus))
        self.assertRaises(ValueError, waiter.state, 'srvc', juju_env='test')
Esempio n. 11
0
 def test_juju(self):
     self.assertEqual(str(JujuVersion()), juju(['version']).split('-')[0])
Esempio n. 12
0
 def test_status_py(self, mj, mpy):
     mj.side_effect = [JujuVersion(0, 7, 0, False)]
     waiter.status('pyjuju')
     mpy.assert_called_with('pyjuju')
Esempio n. 13
0
 def test_juju(self):
     self.assertEqual(str(JujuVersion()),
                      juju(['version'], include_model=False).split('-')[0])