Beispiel #1
0
 def test_vm_in_range_accepted_after_didnot_run(self):
     vm = self._get_vm(0, 0)
     stime = int(self.w_end + HOUR)
     vm.find('slice/' + Computer.VM_STARTTIME_ELEM).text = str(stime)
     cmptr = Computer(self.w_start, self.w_end, '', True)
     cmptr._query_etime_from_vm_details = cmptr.get_etime
     assert False == cmptr.vm_in_range(vm)
Beispiel #2
0
 def test_vm_in_range_started_before_still_running(self):
     stime = int(self.w_start - HOUR)
     etime = 0
     vm = self._get_vm(stime, etime)
     cmptr = Computer(self.w_start, self.w_end, '', True)
     cmptr._query_etime_from_vm_details = cmptr.get_etime
     assert True == cmptr.vm_in_range(vm)
Beispiel #3
0
    def test_compute_totals(self):
        cmptr = Computer(0, 0, '', True)
        root = ET.fromstring(USAGERECORD_XML)
        cmptr.compute_totals(root)

        assert '1' == root.get('total_time')
        assert '1' == root.get('total_cpu')
        assert '1' == root.get('total_ram')
        assert '2' == root.get('total_disk')
        assert '1' == root.get('total_net_rx')
        assert '1' == root.get('total_net_tx')
Beispiel #4
0
 def _update_and_assert(self, vm, delta_time_hours):
     cmptr = Computer(self.w_start, self.w_end, '', True)
     cmptr._query_etime_from_vm_details = cmptr.get_etime
     cmptr._update_time_on_vm(vm)
     assert delta_time_hours == int(vm.find('time').text)
Beispiel #5
0
 def test_get_size_from_marketplace(self):
     cmptr = Computer(self.w_start, self.w_end, '', True)
     cmptr._query_etime_from_vm_details = cmptr.get_etime
     cmptr._get_url = Mock(return_value=IMAGE_MANIFEST)
     assert DISK_SIZE == cmptr.get_size_from_marketplace('http://foo.bar/baz')
     assert DISK_SIZE == cmptr.marketplaceSizeCache['http://foo.bar/baz']
Beispiel #6
0
 def test_vm_in_range_started_after(self):
     stime = int(self.w_end + HOUR)
     etime = stime + HOUR
     vm = self._get_vm(stime, etime)
     cmptr = Computer(self.w_start, self.w_end, '', True)
     assert False == cmptr.vm_in_range(vm)
Beispiel #7
0
 def test_vm_in_range_ended_before(self):
     etime = int(self.w_start - HOUR)
     stime = etime - HOUR
     vm = self._get_vm(stime, etime)
     cmptr = Computer(self.w_start, self.w_end, '', True)
     assert False == cmptr.vm_in_range(vm)