コード例 #1
0
ファイル: test_filter.py プロジェクト: tiborsimon/projects
 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)
コード例 #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)
コード例 #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)
コード例 #4
0
ファイル: test_filter.py プロジェクト: tiborsimon/projects
 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)
コード例 #5
0
ファイル: test_filter.py プロジェクト: tiborsimon/projects
 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)
コード例 #6
0
ファイル: test_filter.py プロジェクト: tiborsimon/projects
 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)
コード例 #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)
コード例 #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)