def test_find_by_name_invalid_collector(self):
     error_response = {'error': "Metric Collector '{}' not found.".format(self.subject.name)}
     response = Mock()
     response.json = Mock(return_value=error_response)
     with patch.object(MetricCollectorDetails, 'request') as metric_collector_details_request:
         metric_collector_details_request.side_effect=KalibroClientRequestError(response)
         MetricCollectorDetails.find_by_name(self.subject.name)
         metric_collector_details_request.assert_called_once
 def test_all_names(self):
     names = ['Analizo', 'MetricFu']
     with patch.object(MetricCollectorDetails, 'request',
                       return_value={'metric_collector_names': names}) as metric_collector_details_request:
         all_names = MetricCollectorDetails.all_names()
         assert_equal(all_names, names)
         metric_collector_details_request.assert_called_once_with('names', method='get')
def step_impl(context):
    context.all_names = MetricCollectorDetails.all_names()
def step_impl(context):
    try:
        MetricCollectorDetails.find_by_name("Avalio")
    except KalibroClientError as exception:
        context.response = exception
def step_impl(context):
    context.metric_fu_etails = MetricCollectorDetails.find_by_name("MetricFu")
 def test_all(self):
     with patch.object(MetricCollectorDetails, 'request',
                       return_value=[self.subject._asdict()]) as metric_collector_details_request:
         all_metric_collectors = MetricCollectorDetails.all()
         assert_equal(all_metric_collectors, [self.subject])
         metric_collector_details_request.assert_called_once_with('', method='get')
    def test_find_by_name(self):
        with patch.object(MetricCollectorDetails, 'request',
                          return_value={'metric_collector_details': self.subject._asdict()}) as metric_collector_details_request:
            assert_equal(MetricCollectorDetails.find_by_name(self.subject.name), self.subject)

            metric_collector_details_request.assert_called_once_with('find', params={"name": self.subject.name})