def test_validate_no_ipmi_instance(self, zboot, ipmi):
        instance = ZerobootIpmiHost(name="test", data=self._valid_data)

        zboot.list = MagicMock(return_value=[self._valid_data['zerobootClient']])
        ipmi.list = MagicMock(return_value=[])
        instance.power_status = MagicMock(return_value=True)

        with pytest.raises(LookupError, message="ipmi instance should not be present") as excinfo:
            instance.validate()
        if "ipmi client" not in str(excinfo.value):
            pytest.fail("Received unexpected error message for missing ipmi instance: %s" % str(excinfo.value))
    def test_validation_required_fields(self, zboot, ipmi):
        zboot.list = MagicMock(return_value=[self._valid_data['zerobootClient']])
        ipmi.list = MagicMock(return_value=[self._valid_data['ipmiClient']])

        test_cases = [
            {
                'data': {
                    'ipmiClient': 'zboot1-ipmi',
                    'mac': 'well:this:a:weird:mac:address',
                    'ip': '10.10.1.1',
                    'network': '10.10.1.0/24',
                    'hostname': 'test-01',
                    'lkrnUrl': 'some.ixpe.url',
                },
                'message': "Should fail: missing zerobootClient",
                'missing': 'zerobootClient',
            },
            {
                'data': {
                    'zerobootClient': 'zboot1-zb',
                    'mac': 'well:this:a:weird:mac:address',
                    'ip': '10.10.1.1',
                    'network': '10.10.1.0/24',
                    'hostname': 'test-01',
                    'lkrnUrl': 'some.ixpe.url',
                },
                'message': "Should fail: missing ipmiClient",
                'missing': 'ipmiClient',
            },
            {
                'data': {
                    'zerobootClient': 'zboot1-zb',
                    'ipmiClient': 'zboot1-ipmi',
                    'mac': 'well:this:a:weird:mac:address',
                    'ip': '10.10.1.1',
                    'hostname': 'test-01',
                    'lkrnUrl': 'some.ixpe.url',
                },
                'message': "Should fail: missing network",
                'missing': 'network',
            },
            {
                'data': {
                    'zerobootClient': 'zboot1-zb',
                    'ipmiClient': 'zboot1-ipmi',
                    'mac': 'well:this:a:weird:mac:address',
                    'ip': '10.10.1.1',
                    'network': '10.10.1.0/24',
                    'lkrnUrl': 'some.ixpe.url',
                },
                'message': "Should fail: missing hostname",
                'missing': 'hostname',
            },
            {
                'data': {
                    'zerobootClient': 'zboot1-zb',
                    'ipmiClient': 'zboot1-ipmi',
                    'ip': '10.10.1.1',
                    'network': '10.10.1.0/24',
                    'hostname': 'test-01',
                    'lkrnUrl': 'some.ixpe.url',
                },
                'message': "Should fail: missing mac address",
                'missing': 'mac',
            },
            {
                'data': {
                    'zerobootClient': 'zboot1-zb',
                    'ipmiClient': 'zboot1-ipmi',
                    'network': '10.10.1.0/24',
                    'mac': 'well:this:a:weird:mac:address',
                    'hostname': 'test-01',
                },
                'message': "Should fail: missing ip address",
                'missing': 'ip',
            },
        ]

        for tc in test_cases:
            instance = ZerobootIpmiHost(name="test", data=tc['data'])

            with pytest.raises(
                    ValueError, message="Unexpected success: %s\n\nData: %s" %(tc['message'], tc['data'])) as excinfo:
                instance.validate()
            
            if tc['missing'] not in str(excinfo):
                pytest.fail(
                    "Error message did not contain missing field('%s'): %s" % (tc['missing'], str(excinfo)))