Ejemplo n.º 1
0
 def test__transformation_with_single_selection_in_the_middle(self):
     data = [
         {
             'string': 'abc',
             'selection': (
                 (1, 2),
             )
         }
     ]
     expected = [
         [
             {
                 'string': 'a',
                 'highlight': False
             },
             {
                 'string': 'b',
                 'highlight': True
             },
             {
                 'string': 'c',
                 'highlight': False
             }
         ]
     ]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 2
0
 def test__transformation_with_two_selections(self):
     data = [{
         'string': 'abcdef',
         'selection': (
             (1, 2),
             (3, 5),
         )
     }]
     expected = [[{
         'string': 'a',
         'highlight': False
     }, {
         'string': 'b',
         'highlight': True
     }, {
         'string': 'c',
         'highlight': False
     }, {
         'string': 'de',
         'highlight': True
     }, {
         'string': 'f',
         'highlight': False
     }]]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 3
0
 def test__transformation_with_single_selection_in_the_end(self):
     data = [{'string': 'abc', 'selection': ((2, 3), )}]
     expected = [[{
         'string': 'ab',
         'highlight': False
     }, {
         'string': 'c',
         'highlight': True
     }]]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 4
0
 def test__transformation_with_no_selection__returns_the_whole_line(self):
     data = [
         {
             'string': 'abc',
             'selection': ()
         }
     ]
     expected = [
         [
             {
                 'string': 'abc',
                 'highlight': False
             }
         ]
     ]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 5
0
 def test__transformation_with_full_word_selected(self):
     data = [
         {
             'string': 'abc',
             'selection': (
                 (0, 3),
             )
         }
     ]
     expected = [
         [
             {
                 'string': 'abc',
                 'highlight': True
             }
         ]
     ]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 6
0
 def test__transformation_with_two_selections(self):
     data = [
         {
             'string': 'abcdef',
             'selection': (
                 (1, 2),
                 (3, 5),
             )
         }
     ]
     expected = [
         [
             {
                 'string': 'a',
                 'highlight': False
             },
             {
                 'string': 'b',
                 'highlight': True
             },
             {
                 'string': 'c',
                 'highlight': False
             },
             {
                 'string': 'de',
                 'highlight': True
             },
             {
                 'string': 'f',
                 'highlight': False
             }
         ]
     ]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 7
0
 def test__transformation_with_full_word_selected(self):
     data = [{'string': 'abc', 'selection': ((0, 3), )}]
     expected = [[{'string': 'abc', 'highlight': True}]]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)
Ejemplo n.º 8
0
 def test__transformation_with_no_selection__returns_the_whole_line(self):
     data = [{'string': 'abc', 'selection': ()}]
     expected = [[{'string': 'abc', 'highlight': False}]]
     result = project_selector._transform_data(data)
     self.assertEqual(expected, result)