import unittest

from lymph.core.monitoring.metrics import RawMetric
from lymph.core.monitoring.aggregator import Aggregator


def _get_metrics_one():
    yield RawMetric('dummy', 'one')


def _get_metrics_two():
    yield RawMetric('dummy', 'two')


@unittest.skip("This is unfortunately broken. Please fix it.")
class AggregatorTestCase(unittest.TestCase):

    def test_aggregator_one_component(self):
        aggr = Aggregator(_get_metrics_one, name='test')

        self.assertEqual(list(aggr.get_metrics()), [('dummy', 'one', {'name': 'test'})])

    def test_aggregator_multiple_components(self):
        aggr = Aggregator(_get_metrics_one, _get_metrics_two, name='test')

        self.assertEqual(list(aggr.get_metrics()), [
            ('dummy', 'one', {'name': 'test'}),
            ('dummy', 'two', {'name': 'test'}),
        ])

    def test_aggregator_add_multiple_tags(self):
        aggr = Aggregator(_get_metrics_one, name='test')

        aggr.add_tags(origin='localhost', time='now')

        self.assertEqual(list(aggr.get_metrics()), [
            ('dummy', 'one', {'name': 'test', 'origin': 'localhost', 'time': 'now'})
        ])

@@ -248,71 +248,8 @@
 )%0A%0A%0A
-@unittest.skip(%22This is unfortunately broken. Please fix it.%22)%0A
 clas
@@ -416,41 +416,11 @@
 sert
-Equal(list(aggr.get_metrics()), %5B
+In(
 ('du
@@ -449,17 +449,42 @@
 'test'%7D)
-%5D
+, list(aggr.get_metrics())
 )%0A%0A    d
@@ -628,102 +628,95 @@
 sert
-Equal(list(aggr.get_metrics()), %5B%0A            ('dummy', 'one', %7B'name': 'test'%7D),%0A            
+In(('dummy', 'one', %7B'name': 'test'%7D), list(aggr.get_metrics()))%0A        self.assertIn(
 ('du
@@ -746,26 +746,41 @@
 test'%7D),
-%0A        %5D
+ list(aggr.get_metrics())
 )%0A%0A    d
@@ -959,54 +959,11 @@
 sert
-Equal(list(aggr.get_metrics()), %5B%0A            
+In(
 ('du
@@ -1034,16 +1034,32 @@
 w'%7D)
-%0A        %5D
+, list(aggr.get_metrics())
 )%0A

Fix monitoring aggregator tests