Exemplo n.º 1
0
 def test_dimensions_search_sizing_7_4(self):
     # Likely maximum permitted; 7 keys of 4 items each.
     dimensions = {str(k): ["01234567890123456789" * i for i in xrange(1, 4)] for k in xrange(7)}
     items = tuple(
         sorted(task_to_run._hash_dimensions(utils.encode_to_json(i)) for i in task_to_run._powerset(dimensions))
     )
     self.assertEqual(16384, len(items))
Exemplo n.º 2
0
 def test_dimensions_search_sizing_14_1(self):
     dimensions = {str(k): '01234567890123456789' for k in xrange(14)}
     items = tuple(
         sorted(
             task_to_run._hash_dimensions(utils.encode_to_json(i))
             for i in task_to_run._powerset(dimensions)))
     self.assertEqual(16384, len(items))
Exemplo n.º 3
0
 def test_dimensions_search_sizing_1_20(self):
   # Multi-value dimensions must *always* be prefered to split variables. They
   # are much quicker to search.
   dimensions = {'0': ['01234567890123456789' * i for i in xrange(1, 20)]}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(20, len(items))
Exemplo n.º 4
0
 def test_dimensions_powerset_count(self):
     dimensions = {
         'a': ['1', '2'],
         'b': 'code',
         'd': ['3', '4'],
     }
     self.assertEqual(task_to_run.dimensions_powerset_count(dimensions),
                      len(list(task_to_run._powerset(dimensions))))
Exemplo n.º 5
0
 def test_dimensions_search_sizing_1_20(self):
   # Multi-value dimensions must *always* be prefered to split variables. They
   # are much quicker to search.
   dimensions = {'0': ['01234567890123456789' * i for i in xrange(1, 20)]}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(20, len(items))
Exemplo n.º 6
0
 def test_dimensions_powerset_count(self):
   dimensions = {
     'a': ['1', '2'],
     'b': 'code',
     'd': ['3', '4'],
   }
   self.assertEqual(
       task_to_run.dimensions_powerset_count(dimensions),
       len(list(task_to_run._powerset(dimensions))))
Exemplo n.º 7
0
 def test_dimensions_search_sizing_7_4(self):
   # Likely maximum permitted; 7 keys of 4 items each.
   dimensions = {
     str(k): ['01234567890123456789' * i for i in xrange(1, 4)]
     for k in xrange(7)
   }
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(16384, len(items))
Exemplo n.º 8
0
 def test_powerset(self):
   # tuples of (input, expected).
   # TODO(maruel): We'd want the code to deterministically try 'Windows-6.1'
   # before 'Windows'. Probably do a reverse() on the values?
   data = [
     ({'OS': 'Windows'}, [{'OS': 'Windows'}, {}]),
     (
       {'OS': ['Windows', 'Windows-6.1']},
       [{'OS': 'Windows'}, {'OS': 'Windows-6.1'}, {}],
     ),
     (
       {'OS': ['Windows', 'Windows-6.1'], 'hostname': 'foo'},
       [
         {'OS': 'Windows', 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'hostname': 'foo'},
         {'OS': 'Windows'},
         {'OS': 'Windows-6.1'},
         {'hostname': 'foo'},
         {},
       ],
     ),
     (
       {'OS': ['Windows', 'Windows-6.1'], 'hostname': 'foo', 'bar': [2, 3]},
       [
        {'OS': 'Windows', 'bar': 2, 'hostname': 'foo'},
         {'OS': 'Windows', 'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'bar': 2, 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows', 'bar': 2},
         {'OS': 'Windows', 'bar': 3},
         {'OS': 'Windows-6.1', 'bar': 2},
         {'OS': 'Windows-6.1', 'bar': 3},
         {'OS': 'Windows', 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'hostname': 'foo'},
         {'bar': 2, 'hostname': 'foo'},
         {'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows'},
         {'OS': 'Windows-6.1'},
         {'bar': 2},
         {'bar': 3},
         {'hostname': 'foo'},
         {},
       ],
     ),
   ]
   for inputs, expected in data:
     actual = list(task_to_run._powerset(inputs))
     self.assertEquals(expected, actual)
Exemplo n.º 9
0
 def test_powerset(self):
   # tuples of (input, expected).
   # TODO(maruel): We'd want the code to deterministically try 'Windows-6.1'
   # before 'Windows'. Probably do a reverse() on the values?
   data = [
     ({'OS': 'Windows'}, [{'OS': 'Windows'}, {}]),
     (
       {'OS': ['Windows', 'Windows-6.1']},
       [{'OS': 'Windows'}, {'OS': 'Windows-6.1'}, {}],
     ),
     (
       {'OS': ['Windows', 'Windows-6.1'], 'hostname': 'foo'},
       [
         {'OS': 'Windows', 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'hostname': 'foo'},
         {'OS': 'Windows'},
         {'OS': 'Windows-6.1'},
         {'hostname': 'foo'},
         {},
       ],
     ),
     (
       {'OS': ['Windows', 'Windows-6.1'], 'hostname': 'foo', 'bar': [2, 3]},
       [
        {'OS': 'Windows', 'bar': 2, 'hostname': 'foo'},
         {'OS': 'Windows', 'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'bar': 2, 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows', 'bar': 2},
         {'OS': 'Windows', 'bar': 3},
         {'OS': 'Windows-6.1', 'bar': 2},
         {'OS': 'Windows-6.1', 'bar': 3},
         {'OS': 'Windows', 'hostname': 'foo'},
         {'OS': 'Windows-6.1', 'hostname': 'foo'},
         {'bar': 2, 'hostname': 'foo'},
         {'bar': 3, 'hostname': 'foo'},
         {'OS': 'Windows'},
         {'OS': 'Windows-6.1'},
         {'bar': 2},
         {'bar': 3},
         {'hostname': 'foo'},
         {},
       ],
     ),
   ]
   for inputs, expected in data:
     actual = list(task_to_run._powerset(inputs))
     self.assertEquals(expected, actual)
Exemplo n.º 10
0
 def test_powerset(self):
     # tuples of (input, expected).
     # TODO(maruel): We'd want the code to deterministically try 'Windows-6.1'
     # before 'Windows'. Probably do a reverse() on the values?
     data = [
         ({"OS": "Windows"}, [{"OS": "Windows"}, {}]),
         ({"OS": ["Windows", "Windows-6.1"]}, [{"OS": "Windows"}, {"OS": "Windows-6.1"}, {}]),
         (
             {"OS": ["Windows", "Windows-6.1"], "hostname": "foo"},
             [
                 {"OS": "Windows", "hostname": "foo"},
                 {"OS": "Windows-6.1", "hostname": "foo"},
                 {"OS": "Windows"},
                 {"OS": "Windows-6.1"},
                 {"hostname": "foo"},
                 {},
             ],
         ),
         (
             {"OS": ["Windows", "Windows-6.1"], "hostname": "foo", "bar": [2, 3]},
             [
                 {"OS": "Windows", "bar": 2, "hostname": "foo"},
                 {"OS": "Windows", "bar": 3, "hostname": "foo"},
                 {"OS": "Windows-6.1", "bar": 2, "hostname": "foo"},
                 {"OS": "Windows-6.1", "bar": 3, "hostname": "foo"},
                 {"OS": "Windows", "bar": 2},
                 {"OS": "Windows", "bar": 3},
                 {"OS": "Windows-6.1", "bar": 2},
                 {"OS": "Windows-6.1", "bar": 3},
                 {"OS": "Windows", "hostname": "foo"},
                 {"OS": "Windows-6.1", "hostname": "foo"},
                 {"bar": 2, "hostname": "foo"},
                 {"bar": 3, "hostname": "foo"},
                 {"OS": "Windows"},
                 {"OS": "Windows-6.1"},
                 {"bar": 2},
                 {"bar": 3},
                 {"hostname": "foo"},
                 {},
             ],
         ),
     ]
     for inputs, expected in data:
         actual = list(task_to_run._powerset(inputs))
         self.assertEquals(expected, actual)
Exemplo n.º 11
0
 def test_dimensions_search_sizing_14_1(self):
   dimensions = {str(k): '01234567890123456789' for k in xrange(14)}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(16384, len(items))
Exemplo n.º 12
0
 def test_dimensions_powerset_count(self):
     dimensions = {"a": ["1", "2"], "b": "code", "d": ["3", "4"]}
     self.assertEqual(
         task_to_run.dimensions_powerset_count(dimensions), len(list(task_to_run._powerset(dimensions)))
     )