Ejemplo n.º 1
0
 def test_processing_path_changes7(self):
     fb = NonCallableMock(spec_set=Feedback)
     set_path_manager_data('C:\\bin', '"D:\\%TEST_VAR2%n";E:\\bin', {
         'TEST_VAR': 'i;n',
         'TEST_VAR2': 'b;i'
     })
     app_data = AppData([
         create_app_entry([{
             'name': 'a',
             'version': '1',
             'path_entries': [],
             'keep': True
         }], []),
         create_app_entry([{
             'name': 'b',
             'version': '2',
             'path_entries': []
         }], [])
     ])
     path_processor.process_path_changes(app_data, fb)
     fb.report_path_analysis.assert_called_once()
     fb.confirm_user_path_update.assert_not_called()
     path_manager.set_user_path.assert_not_called()
     path_manager.notify_path_change.assert_not_called()
     fb.report_user_path_updated.assert_not_called()
     fb.report_user_path_no_changes.assert_called_once()
Ejemplo n.º 2
0
 def test_processing_path_changes3(self):
     fb = NonCallableMock(spec_set=Feedback)
     set_path_manager_data('C:\\bin', 'D:\\bi%TEST_VAR%:\\b"in',
                           {'TEST_VAR': 'n;E'})
     app_data = AppData([
         create_app_entry([{
             'name': 'a',
             'version': '1',
             'path_entries': ['F:\\bin'],
             'keep': True
         }], []),
         create_app_entry([{
             'name': 'b',
             'version': '2'
         }], [])
     ])
     with self.assertRaises(InvalidUserPathError):
         path_processor.process_path_changes(app_data, fb)
     fb.report_path_analysis.assert_called_once()
     fb.confirm_user_path_update.assert_not_called()
     fb.report_path_analysis.assert_called_once()
     path_manager.set_user_path.assert_not_called()
     path_manager.notify_path_change.assert_not_called()
     fb.report_user_path_updated.assert_not_called()
     fb.report_user_path_no_changes.assert_not_called()
Ejemplo n.º 3
0
 def test_processing_path_changes6(self):
     fb = NonCallableMock(spec_set=Feedback)
     set_path_manager_data('C:\\bin', 'D:\\bin;E:\\bin', {})
     app_data = AppData([
         create_app_entry([{
             'name': 'a',
             'version': '1',
             'path_entries': ['F:\\bi;n'],
             'keep': True
         }], []),
         create_app_entry([{
             'name': 'b',
             'version': '2'
         }], [])
     ])
     with self.assertRaises(InvalidPathEntryError) as c:
         path_processor.process_path_changes(app_data, fb)
     fb.report_path_analysis.assert_called_once()
     fb.confirm_user_path_update.assert_not_called()
     self.assertEqual(c.exception.entry, 'F:\\bi;n')
     self.assertEqual(
         c.exception.app_entry,
         create_app_entry([{
             'name': 'a',
             'version': '1',
             'path_entries': ['F:\\bi;n'],
             'keep': True
         }], []))
     fb.report_user_path_updated.assert_not_called()
     fb.report_user_path_no_changes.assert_not_called()
     path_manager.set_user_path.assert_not_called()
     path_manager.notify_path_change.assert_not_called()
Ejemplo n.º 4
0
 def test_int_instead_str(self):
     with self.assertRaises(AppDataFieldValueTypeError) as c:
         create_app_entry([{'name': 1}], [ConfigPath('$[2]')])
     self.assertEqual(c.exception.expected, str)
     self.assertEqual(c.exception.received, int)
     self.assertEqual(c.exception.field_name, 'name')
     self.assertSequenceEqual(c.exception.config_paths,
                              [ConfigPath('$[2]')])
Ejemplo n.º 5
0
 def test_circular_reference(self):
     with self.assertRaises(AppDataCircularReferenceError) as c:
         create_app_entry([{
             'name': 'example',
             'version': '1.1',
             'command': '$command'
         }], [ConfigPath('$[1]')])
     self.assertEqual(c.exception.field_name, 'command')
     self.assertSequenceEqual(c.exception.config_paths,
                              [ConfigPath('$[1]')])
Ejemplo n.º 6
0
 def test_no_name(self):
     with self.assertRaises(AppDataMissingFieldError) as c:
         create_app_entry([{
             'version': '1.1'
         }], [ConfigPath('$[1]'),
              ConfigPath('$[1].versions[2]')])
     self.assertEqual(c.exception.field_name, 'name')
     self.assertSequenceEqual(
         c.exception.config_paths,
         [ConfigPath('$[1]'),
          ConfigPath('$[1].versions[2]')])
Ejemplo n.º 7
0
 def test_int_list_instead_str_list(self):
     with self.assertRaises(AppDataFieldValueTypeError) as c:
         create_app_entry([{
             'name': 'example',
             'version': '1.1',
             'install_args': [1, 2, 3]
         }], [ConfigPath('$[3]')])
     self.assertEqual(c.exception.expected, str)
     self.assertEqual(c.exception.received, int)
     self.assertEqual(c.exception.field_name, 'install_args')
     self.assertSequenceEqual(c.exception.config_paths,
                              [ConfigPath('$[3]')])
Ejemplo n.º 8
0
 def test_refinement(self):
     e = create_app_entry([{
         'name': 'example',
         'version': '1.1'
     }, {
         'install_args': ['a', 'b', 'c']
     }], [])
     self.assertSequenceEqual(e.install_args, ['a', 'b', 'c'])
Ejemplo n.º 9
0
 def test_refinement4(self):
     e = create_app_entry([{
         'name': 'example',
         'version': '1.1',
         'command': 'te${a}t'
     }, {
         'a': 's'
     }], [])
     self.assertEqual(e.command, 'test')
Ejemplo n.º 10
0
 def test_refinement_priority(self):
     e = create_app_entry([{
         'name': 'example',
         'version': '1.1',
         'command': '$a',
         'a': 'test'
     }, {
         'a': 'test2'
     }], [])
     self.assertEqual(e.command, 'test2')
Ejemplo n.º 11
0
 def test_list_refinement(self):
     e = create_app_entry([{
         'name': 'example',
         'version': '1.1',
         'install_args': ['a${b}c', 'de$f']
     }, {
         'b': 0,
         'f': 1
     }], [])
     self.assertSequenceEqual(e.install_args, ['a0c', 'de1'])
Ejemplo n.º 12
0
 def test_app_entry_creation(self):
     e = create_app_entry([{'name': 'example', 'version': '1.1'}], [])
     self.assertEqual(e.name, 'example')
     self.assertEqual(e.version, '1.1')