Exemplo n.º 1
0
    def test_get_clear_request(self):
        self._mock_requests()
        clear_request = CloudstackDataLoader('ENV', None)._clear(
            'comp_unit', 'collections', 10000)

        self.assertEqual('CLEAR', clear_request['action'])
        self.assertEqual('comp_unit', clear_request['collection'])
        self.assertEqual('collections', clear_request['type'])
Exemplo n.º 2
0
    def test_load_vm_data_given_no_projects_found(self):
        projects = []
        vms = []
        accounts = []
        acs_mock = self._mock_cloudstack_service(projects, accounts, vms)
        requests_mock = self._mock_requests()
        driver_mock = self._mock_driver()

        CloudstackDataLoader('ENV', driver_mock).run()

        self.assertEqual(1, acs_mock.list_projects.call_count)
        self.assertEqual(0,
                         acs_mock.list_virtual_machines_by_project.call_count)
        self.assertEqual(1, requests_mock.return_value.post.call_count)
Exemplo n.º 3
0
    def test_vms_given_two_vms_found(self):
        projects = [{'id': '3', 'name': 'project A', 'vmtotal': 2}]
        accounts = []
        vms = [{'id': '1'}, {'id': '2'}]
        acs_mock = self._mock_cloudstack_service(projects, accounts, vms)
        requests_mock = self._mock_requests()
        driver_mock = self._mock_driver()

        CloudstackDataLoader('ENV', driver_mock).run()

        self.assertEqual(1, acs_mock.list_projects.call_count)
        acs_mock.list_virtual_machines_by_project.assert_called_once_with(
            '3', 1, 500)
        self.assertEqual(3, requests_mock.return_value.post.call_count)
Exemplo n.º 4
0
    def test_vms_given_one_project_found(self):
        projects = [{'id': '1', 'name': 'project A', 'vmtotal': 1}]
        accounts = []
        vms = []
        acs_mock = self._mock_cloudstack_service(projects, accounts, vms)
        requests_mock = self._mock_requests()
        driver_mock = self._mock_driver()

        CloudstackDataLoader('ENV', driver_mock).run()

        self.assertEqual(1, acs_mock.list_projects.call_count)
        self.assertEqual(1,
                         acs_mock.list_virtual_machines_by_project.call_count)
        self.assertEqual(1, requests_mock.return_value.post.call_count)
Exemplo n.º 5
0
 def full_load(self):
     CloudstackDataLoader(self.env, self._create_updates).run()