Exemplo n.º 1
0
 def test_getting_distinct_values(self):
     data_source, column = self._build_report([
         'apple',
         'apple',
         'banana',
         'blueberry'
     ])
     vals = get_distinct_values(data_source.config, column)[0]
     self.assertListEqual(vals, ['apple', 'banana', 'blueberry'])
Exemplo n.º 2
0
 def test_allowed_expansion(self):
     num_columns = DEFAULT_MAXIMUM_EXPANSION + 1
     vals = ['foo' + str(i) for i in range(num_columns)]
     data_source, column = self._build_report(vals)
     column.max_expansion = num_columns
     distinct_vals, too_many_values = get_distinct_values(
         data_source.config,
         column,
         expansion_limit=num_columns,
     )
     self.assertFalse(too_many_values)
     self.assertEqual(len(distinct_vals), num_columns)
Exemplo n.º 3
0
 def test_allowed_expansion(self):
     num_columns = DEFAULT_MAXIMUM_EXPANSION + 1
     vals = ['foo' + str(i) for i in range(num_columns)]
     data_source, column = self._build_report(vals)
     column.max_expansion = num_columns
     distinct_vals, too_many_values = get_distinct_values(
         data_source.config,
         column,
         expansion_limit=num_columns,
     )
     self.assertFalse(too_many_values)
     self.assertEqual(len(distinct_vals), num_columns)
Exemplo n.º 4
0
 def test_no_distinct_values(self):
     data_source, column = self._build_report([])
     distinct_vals, too_many_values = get_distinct_values(
         data_source.config, column)
     self.assertListEqual(distinct_vals, [])
Exemplo n.º 5
0
 def test_getting_distinct_values(self):
     data_source, column = self._build_report(
         ['apple', 'apple', 'banana', 'blueberry'])
     vals = get_distinct_values(data_source.config, column)[0]
     self.assertListEqual(vals, ['apple', 'banana', 'blueberry'])
Exemplo n.º 6
0
 def test_unbuilt_data_source(self):
     data_source, column = self._build_report(['apple'], build_data_source=False)
     distinct_vals, too_many_values = get_distinct_values(data_source.config, column)
     self.assertListEqual(distinct_vals, [])
     self.assertFalse(too_many_values)
Exemplo n.º 7
0
 def test_too_large_expansion(self):
     vals = ['foo' + str(i) for i in range(DEFAULT_MAXIMUM_EXPANSION + 1)]
     data_source, column = self._build_report(vals)
     distinct_vals, too_many_values = get_distinct_values(data_source.config, column)
     self.assertTrue(too_many_values)
     self.assertEqual(len(distinct_vals), DEFAULT_MAXIMUM_EXPANSION)
Exemplo n.º 8
0
 def test_no_distinct_values(self):
     data_source, column = self._build_report([])
     distinct_vals, too_many_values = get_distinct_values(data_source.config, column)
     self.assertListEqual(distinct_vals, [])
Exemplo n.º 9
0
 def test_unbuilt_data_source(self):
     data_source, column = self._build_report(['apple'], build_data_source=False)
     distinct_vals, too_many_values = get_distinct_values(data_source.config, column)
     self.assertListEqual(distinct_vals, [])
     self.assertFalse(too_many_values)
Exemplo n.º 10
0
 def test_too_large_expansion(self):
     vals = ['foo' + str(i) for i in range(DEFAULT_MAXIMUM_EXPANSION + 1)]
     data_source, column = self._build_report(vals)
     distinct_vals, too_many_values = get_distinct_values(data_source.config, column)
     self.assertTrue(too_many_values)
     self.assertEqual(len(distinct_vals), DEFAULT_MAXIMUM_EXPANSION)