def testMetricDecodeFailure(self): metric = get_branin_metric() sqa_metric = self.encoder.metric_to_sqa(metric) sqa_metric.metric_type = "foobar" with self.assertRaises(SQADecodeError): self.decoder.metric_from_sqa(sqa_metric) sqa_metric.metric_type = METRIC_REGISTRY[BraninMetric] sqa_metric.intent = "foobar" with self.assertRaises(SQADecodeError): self.decoder.metric_from_sqa(sqa_metric) sqa_metric.intent = MetricIntent.TRACKING sqa_metric.properties = {} with self.assertRaises(SQADecodeError): self.decoder.metric_from_sqa(sqa_metric)
def testMetricEncodeFailure(self): metric = get_branin_metric() del metric.__dict__["param_names"] with self.assertRaises(AttributeError): self.encoder.metric_to_sqa(metric)