예제 #1
0
    def test_vm_cputime(self):
        '''
            Test to Return cputime used by the vms
        '''
        ret = {'1': {'cputime_percent': 0, 'cputime': 1}}
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(return_value={'host_CPUs': "1"})
            with patch.object(xapi, "_get_record_by_label", mock):
                mock = MagicMock(return_value={'VCPUs_number': "1",
                                               'VCPUs_utilisation': {'0': '1'}}
                                 )
                with patch.object(xapi, "_get_metrics_record", mock):
                    self.assertDictEqual(xapi.vm_cputime("1"), ret)

            mock = MagicMock(return_value={})
            with patch.object(xapi, "list_domains", mock):
                self.assertDictEqual(xapi.vm_cputime(""), {})
예제 #2
0
    def test_vm_cputime(self):
        '''
            Test to Return cputime used by the vms
        '''
        ret = {'1': {'cputime_percent': 0, 'cputime': 1}}
        with patch.object(xapi, "_get_xapi_session", MagicMock()):
            mock = MagicMock(return_value={'host_CPUs': "1"})
            with patch.object(xapi, "_get_record_by_label", mock):
                mock = MagicMock(return_value={'VCPUs_number': "1",
                                               'VCPUs_utilisation': {'0': '1'}}
                                 )
                with patch.object(xapi, "_get_metrics_record", mock):
                    self.assertDictEqual(xapi.vm_cputime("1"), ret)

            mock = MagicMock(return_value={})
            with patch.object(xapi, "list_vms", mock):
                self.assertDictEqual(xapi.vm_cputime(""), {})