def test_getitem_from_tuple_should_cache_categories_after_first_time(self):
     reporter = IndicadorsMatrixDataReporter(self.client, "service-1")
     reporter._getitem_from_tuple((1, 1))
     with patch(
         "genweb.serveistic.data_access.indicadors." "IndicadorsMatrixDataReporter._retrieve_categories"
     ) as retrieve_categories:
         reporter._getitem_from_tuple((1, 1))
         self.assertEqual(0, retrieve_categories.call_count)
 def test_getitem_should_raise_typeerror_if_item_is_3_element_tuple(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'noservice')
     with self.assertRaises(TypeError) as context:
         reporter[1, 2, 3]
     self.assertEqual(
         "item must be either an integer or a 2-integer tuple",
         context.exception.message)
 def test_getitem_should_call_from_tuple_when_item_is_tuple(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'noservice')
     with patch(
             "genweb.serveistic.data_access.indicadors."
             "IndicadorsMatrixDataReporter._getitem_from_int") as getitem_from_int:
         with patch(
                 "genweb.serveistic.data_access.indicadors."
                 "IndicadorsMatrixDataReporter._getitem_from_tuple") as getitem_from_tuple:
             reporter[1, 2]
         self.assertEqual(1, getitem_from_tuple.call_count)
         self.assertEqual(0, getitem_from_int.call_count)
 def test_getitem_from_tuple_should_cache_categories_after_first_time(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'service-1')
     reporter._getitem_from_tuple((1, 1))
     with patch(
             "genweb.serveistic.data_access.indicadors."
             "IndicadorsMatrixDataReporter._retrieve_categories") as retrieve_categories:
         reporter._getitem_from_tuple((1, 1))
         self.assertEqual(0, retrieve_categories.call_count)
 def test_getitem_from_tuple_should_return_right_category(self):
     reporter = IndicadorsMatrixDataReporter(self.client, "service-1")
     self.assertEquals("category-1.2", reporter._getitem_from_tuple((1, 2)).identifier)
 def test_getitem_from_tuple_should_raise_indexerror_if_index_is_gtsize(self):
     reporter = IndicadorsMatrixDataReporter(self.client, "service-1")
     with self.assertRaises(IndexError):
         reporter._getitem_from_tuple((1, 4))
 def test_getitem_from_int_should_return_right_indicator(self):
     reporter = IndicadorsMatrixDataReporter(self.client, "service-1")
     self.assertEquals("indicator-2", reporter._getitem_from_int(2).identifier)
 def test_getitem_from_int_should_raise_indexerror_if_index_is_lt1(self):
     reporter = IndicadorsMatrixDataReporter(self.client, "service-1")
     with self.assertRaises(IndexError):
         reporter._getitem_from_int(0)
 def test_getitem_should_not_raise_typeerror_if_item_is_int(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'noservice')
     with patch(
             "genweb.serveistic.data_access.indicadors."
             "IndicadorsMatrixDataReporter._getitem_from_int") as getitem_from_int:
         reporter[1]
 def test_getitem_should_raise_indexerror_when_service_does_not_exist(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'noservice')
     with self.assertRaises(IndexError):
         reporter[1]
     with self.assertRaises(IndexError):
         reporter[1, 1]
 def test_getitem_from_tuple_should_return_right_category(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'service-1')
     self.assertEquals(
         'category-1.2', reporter._getitem_from_tuple((1, 2)).identifier)
 def test_getitem_from_tuple_should_raise_indexerror_if_index_is_gtsize(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'service-1')
     with self.assertRaises(IndexError):
         reporter._getitem_from_tuple((1, 4))
 def test_getitem_from_int_should_return_right_indicator(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'service-1')
     self.assertEquals(
         'indicator-2', reporter._getitem_from_int(2).identifier)
 def test_getitem_from_int_should_raise_indexerror_if_index_is_lt1(self):
     reporter = IndicadorsMatrixDataReporter(self.client, 'service-1')
     with self.assertRaises(IndexError):
         reporter._getitem_from_int(0)