def test_panoptes_metrics_group_set(self):
        """Tests basic PanoptesMetricsGroupSet operations"""
        metrics_group_set = PanoptesMetricsGroupSet()
        metrics_group = PanoptesMetricsGroup(self.__panoptes_resource, u'test',
                                             120)
        metrics_group_two = PanoptesMetricsGroup(self.__panoptes_resource,
                                                 u'test', 120)
        metrics_group_set.add(metrics_group)
        metrics_group_set.add(metrics_group_two)
        assert len(metrics_group_set) == 1
        self.assertIn(metrics_group, metrics_group_set.metrics_groups)

        metrics_group_set.remove(metrics_group_two)
        assert len(metrics_group_set) == 0

        metrics_group_set.add(metrics_group)
        metrics_group_three = PanoptesMetricsGroup(self.__panoptes_resource,
                                                   u'test3', 120)
        metrics_group_three.add_metric(
            PanoptesMetric(u"test3", 0.0, PanoptesMetricType.GAUGE))
        metrics_group_set.add(metrics_group_three)
        assert len(metrics_group_set) == 2

        metrics_group_set_two = PanoptesMetricsGroupSet()
        metrics_group_four = PanoptesMetricsGroup(self.__panoptes_resource,
                                                  u'test', 120)
        metrics_group_four.add_metric(
            PanoptesMetric(u"test4", 0.0, PanoptesMetricType.GAUGE))
        metrics_group_set_two.add(metrics_group_four)
        assert len(metrics_group_set_two) == 1

        #  Test PanoptesMetricsGroupSet.__add__
        metrics_group_set_union = metrics_group_set + metrics_group_set_two
        assert len(metrics_group_set_union) == 3

        with self.assertRaises(AssertionError):
            metrics_group_set.remove(self.__panoptes_resource)

        with self.assertRaises(TypeError):
            metrics_group_set + metrics_group

        #  Test PanoptesMetricsGroupSet.__iter__ & 'next'
        metrics_group_count = 0
        metrics_group_set_union_interator = iter(metrics_group_set_union)
        for _ in metrics_group_set_union:
            self.assertIn(next(metrics_group_set_union_interator),
                          metrics_group_set_union.metrics_groups)
            metrics_group_count += 1
        assert len(metrics_group_set_union) == metrics_group_count
        with self.assertRaises(Exception):
            next(metrics_group_set_union_interator)

        #  Test PanoptesMetricsGroupSet.__repr__
        _METRICS_GROUP_SET_REPR = u"PanoptesMetricsGroupSet[PanoptesMetricsGroup[resource:" \
                                  u"plugin|test|site|test|class|test|subclass|test|type|test|id|test|endpoint|test," \
                                  u"interval:120,schema_version:0.2,group_type:test,creation_timestamp:{}," \
                                  u"dimensions:[],metrics:[]],PanoptesMetricsGroup[resource:" \
                                  u"plugin|test|site|test|class|test|subclass|test|type|test|id|test|endpoint|test," \
                                  u"interval:120,schema_version:0.2,group_type:test3,creation_timestamp:{}," \
                                  u"dimensions:[],metrics:[" \
                                  u"PanoptesMetric[test3|0.0|GAUGE|{}]]]]".format(mock_time.return_value,
                                                                                  mock_time.return_value,
                                                                                  mock_time.return_value)

        self.assertEqual(repr(metrics_group_set), _METRICS_GROUP_SET_REPR)
    def test_panoptes_metrics_group_set(self):
        """Tests basic PanoptesMetricsGroupSet operations"""
        metrics_group_set = PanoptesMetricsGroupSet()
        metrics_group = PanoptesMetricsGroup(self.__panoptes_resource, 'test',
                                             120)
        metrics_group_two = PanoptesMetricsGroup(self.__panoptes_resource,
                                                 'test', 120)
        metrics_group_set.add(metrics_group)
        metrics_group_set.add(metrics_group_two)
        assert len(metrics_group_set) == 1
        self.assertIn(metrics_group, metrics_group_set.metrics_groups)

        metrics_group_set.remove(metrics_group_two)
        assert len(metrics_group_set) == 0

        metrics_group_set.add(metrics_group)
        metrics_group_three = PanoptesMetricsGroup(self.__panoptes_resource,
                                                   'test3', 120)
        metrics_group_three.add_metric(
            PanoptesMetric("test3", 0.0, PanoptesMetricType.GAUGE))
        metrics_group_set.add(metrics_group_three)
        assert len(metrics_group_set) == 2

        metrics_group_set_two = PanoptesMetricsGroupSet()
        metrics_group_four = PanoptesMetricsGroup(self.__panoptes_resource,
                                                  'test', 120)
        metrics_group_four.add_metric(
            PanoptesMetric("test4", 0.0, PanoptesMetricType.GAUGE))
        metrics_group_set_two.add(metrics_group_four)
        assert len(metrics_group_set_two) == 1

        #  Test PanoptesMetricsGroupSet.__add__
        metrics_group_set_union = metrics_group_set + metrics_group_set_two
        assert len(metrics_group_set_union) == 3

        with self.assertRaises(AssertionError):
            metrics_group_set.remove(self.__panoptes_resource)

        with self.assertRaises(TypeError):
            metrics_group_set + metrics_group

        #  Test PanoptesMetricsGroupSet.__iter__ & 'next'
        metrics_group_count = 0
        metrics_group_set_union_interator = iter(metrics_group_set_union)
        for _ in metrics_group_set_union:
            self.assertIn(metrics_group_set_union_interator.next(),
                          metrics_group_set_union.metrics_groups)
            metrics_group_count += 1
        assert len(metrics_group_set_union) == metrics_group_count
        with self.assertRaises(Exception):
            metrics_group_set_union_interator.next()

        #  Test PanoptesMetricsGroupSet.__repr__
        _METRICS_GROUP_SET_REPR = "set([{{'metrics_group_interval': 120, " \
                                  "'resource': plugin|test|site|test|class|test|subclass|test|type|test|id|test|" \
                                  "endpoint|test, 'dimensions': set([]), 'metrics_group_type': 'test', " \
                                  "'metrics': set([]), 'metrics_group_creation_timestamp': {}, " \
                                  "'metrics_group_schema_version': '0.2'}}, {{'metrics_group_interval': 120, " \
                                  "'resource': plugin|test|site|test|class|test|subclass|test|type|test|id|test|" \
                                  "endpoint|test, 'dimensions': set([]), 'metrics_group_type': 'test3', " \
                                  "'metrics': set([{{'metric_creation_timestamp': {}, " \
                                  "'metric_type': 'gauge', " \
                                  "'metric_name': 'test3', 'metric_value': 0.0}}]), " \
                                  "'metrics_group_creation_timestamp': {}, " \
                                  "'metrics_group_schema_version': '0.2'}}])".format(mock_time.return_value,
                                                                                     mock_time.return_value,
                                                                                     mock_time.return_value)
        self.assertEqual(repr(metrics_group_set), _METRICS_GROUP_SET_REPR)