Beispiel #1
0
 def test_include_raw_complex(self):
     """
     combine(include_raw=True) with complex input
     """
     paths = ["a.1.b.1", "a.1.b.2", "a.2.b.1", "a.2.b.2"]
     result = combine(paths, [3], True)
     eq_(result,
         {
             "a.{1,2}.b.1": ["a.1.b.1", "a.2.b.1"],
             "a.{1,2}.b.2": ["a.1.b.2", "a.2.b.2"]
         }
     )
Beispiel #2
0
 def test_expansions(self):
     # Remember that expansion indexes apply only to wildcard slots,
     # which here are slots which differ from path to path and would thus
     # get combined by default.
     for desc, inputs, expansions, results in (
         ("Expand second part",
             ["foo.bar", "foo.biz"], [1], ["foo.bar", "foo.biz"]),
         ("Expand both parts",
             ["1.2", "3.4"], [0, 1], ["1.2", "3.4"]),
     ):
         eq_.description = desc
         yield eq_, set(map(str, combine(inputs, expansions))), set(results)
         del eq_.description
Beispiel #3
0
 def test_combinations(self):
     for desc, inputs, results in (
         ("Single metric, no combinations",
             ("foo.bar",), "foo.bar"),
         ("Single combination at end",
             ("foo.bar", "foo.biz"), "foo.{bar,biz}"),
         ("Combinations in both of two positions",
             ("foo.bar", "biz.baz"), "{foo,biz}.{bar,baz}"),
         ("One combination in the 2nd of 3 positions",
             ("foo.1.bar", "foo.2.bar"), "foo.{1,2}.bar"),
         ("Two combinations surrounding one normal part",
             ("foo.name.bar", "biz.name.baz"), "{foo,biz}.name.{bar,baz}"),
     ):
         eq_.description = desc
         yield eq_, map(str, combine(inputs)), [results]
         del eq_.description
Beispiel #4
0
 def test_include_raw_no_expansions(self):
     """
     combine(include_raw=True) without expansions
     """
     result = combine(["foo.bar", "foo.biz"], [], True)
     eq_(result, {"foo.{bar,biz}": ["foo.bar", "foo.biz"]})
Beispiel #5
0
 def test_include_raw_expansions(self):
     """
     combine(include_raw=True) with expansions
     """
     result = combine(["foo.bar", "foo.biz"], [1], True)
     eq_(result, {"foo.bar": ["foo.bar"], "foo.biz": ["foo.biz"]})