コード例 #1
0
ファイル: task_to_run_test.py プロジェクト: misscache/luci-py
 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))
コード例 #2
0
ファイル: task_to_run_test.py プロジェクト: pombreda/luci-py
 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))
コード例 #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))
コード例 #4
0
ファイル: task_to_run_test.py プロジェクト: pombreda/luci-py
 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))))
コード例 #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))
コード例 #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))))
コード例 #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))
コード例 #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)
コード例 #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)
コード例 #10
0
ファイル: task_to_run_test.py プロジェクト: misscache/luci-py
 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)
コード例 #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))
コード例 #12
0
ファイル: task_to_run_test.py プロジェクト: misscache/luci-py
 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)))
     )