def test_get_server_by_ilo_address_with_no_registered_servers(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([]) ] icsphelper = ICspHelper(self.mock_connection) server = icsphelper.get_server_by_ilo_address('16.124.135.239') self.mock_connection.get.assert_called_once_with( '/rest/os-deployment-servers/?count=-1') self.assertIsNone(server)
def test_get_server_by_ilo_address_with_non_matching_result(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([DEFAULT_SERVER]) ] icsphelper = ICspHelper(self.mock_connection) server = icsphelper.get_server_by_ilo_address('16.124.135.255') self.mock_connection.get.assert_called_once_with( '/rest/os-deployment-servers/?count=-1') self.assertIsNone(server)
def test_should_fail_when_os_build_plan_not_found(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([]) ] icsphelper = ICspHelper(self.mock_connection) plan = icsphelper.get_build_plan('RHEL 7.2 x64') self.mock_connection.get.assert_called_once_with( '/rest/index/resources?filter="name=\'RHEL%207.2%20x64\'"&category=osdbuildplan' ) self.assertIsNone(plan)
def test_get_build_plan_with_non_matching_result(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([DEFAULT_BUILD_PLAN]) ] icsphelper = ICspHelper(self.mock_connection) plan = icsphelper.get_build_plan('BuildPlan') self.mock_connection.get.assert_called_once_with( '/rest/index/resources?filter="name=\'BuildPlan\'"&category=osdbuildplan' ) self.assertIsNone(plan)
def test_get_server_by_serial_with_no_registered_servers(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([]) ] icsphelper = ICspHelper(self.mock_connection) server = icsphelper.get_server_by_serial('000') self.mock_connection.get.assert_called_once_with( '/rest/index/resources?category=osdserver&query=\'osdServerSerialNumber:"000"\'' ) self.assertIsNone(server)
def test_get_server_by_serial_with_matching_result(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([DEFAULT_SERVER]) ] icsphelper = ICspHelper(self.mock_connection) server = icsphelper.get_server_by_serial('VCGYZ33007') expected = {'uri': '/rest/os-deployment-servers/123456'} self.mock_connection.get.assert_called_once_with( '/rest/index/resources?category=osdserver&query=\'osdServerSerialNumber:"VCGYZ33007"\'' ) self.assertEqual(server, expected)
def test_get_build_plan_with_matching_result(self): self.mock_connection.get.side_effect = [ self.get_as_rest_collection([DEFAULT_BUILD_PLAN]) ] icsphelper = ICspHelper(self.mock_connection) plan = icsphelper.get_build_plan('RHEL 7.2 x64') expected = { 'name': 'RHEL 7.2 x64', 'uri': '/rest/os-deployment-build-plans/222' } self.mock_connection.get.assert_called_once_with( '/rest/index/resources?filter="name=\'RHEL%207.2%20x64\'"&category=osdbuildplan' ) self.assertEqual(plan, expected)