Esempio n. 1
0
    def test_load_one_vm(self, mprocess_vmrecord):
        host = MagicMock()

        mvm_rec = MagicMock()

        host.client.get_all_vm_records.return_value = {'test_rec': mvm_rec}

        dm = DockerMonitor(host)
        dm.refresh()

        host.client.get_all_vm_records.assert_called_once_with()
        mprocess_vmrecord.assert_called_with('test_rec', mvm_rec)
Esempio n. 2
0
    def test_load_all_vm(self, mprocess_vmrecord):
        host = MagicMock()

        # Mock out the vm_ref: vm_rec dictionary object
        mvm_recs = {}
        n = 10
        for i in range(n):
            mvm_recs["rec_%d" % i] = MagicMock()

        host.client.get_all_vm_records.return_value = mvm_recs

        dm = DockerMonitor(host)
        dm.refresh()

        host.client.get_all_vm_records.assert_called_once_with()

        # Assert we process every record.
        self.assertEqual(mprocess_vmrecord.call_count, n)