def test_get_virtualenv_directory_is_in_virtualenv(self):
     with mock.patch('ievv_opensource.utils.virtualenvutils.sys.real_prefix',
                     '/real'):
         with mock.patch('ievv_opensource.utils.virtualenvutils.sys.prefix',
                         '/virtual'):
             self.assertEqual('/virtual',
                              virtualenvutils.get_virtualenv_directory())
 def test_add_virtualenv_bin_directory_to_path(self):
     mockenviron = {'PATH': ''}
     with mock.patch('ievv_opensource.utils.virtualenvutils.sys.real_prefix',
                     '/real'):
         with mock.patch('ievv_opensource.utils.virtualenvutils.sys.prefix',
                         '/virtual'):
             with mock.patch('ievv_opensource.utils.virtualenvutils.os.environ',
                             mockenviron):
                 virtualenvutils.add_virtualenv_bin_directory_to_path()
     self.assertEqual('{}/virtual/bin'.format(os.pathsep),
                      mockenviron['PATH'])
 def test_opendocs(self):
     openfile_mock = mock.MagicMock()
     with self.settings(IEVVTASKS_DOCS_BUILD_DIRECTORY=self.documentation_build_directory):
         with mock.patch('ievv_opensource.ievvtasks_development.management.commands.'
                         'ievvtasks_docs.open_file_with_default_os_opener',
                         openfile_mock):
             management.call_command('ievvtasks_docs', open=True)
     openfile_mock.assert_called_once_with(os.path.join(
         self.documentation_build_directory, 'index.html'))
Esempio n. 4
0
 def test_finish_failed(self):
     batchoperation = mommy.prepare('ievv_batchframework.BatchOperation',
                                    status=BatchOperation.STATUS_RUNNING,
                                    started_running_datetime=timezone.now())
     mocknow = datetimeutils.default_timezone_datetime(2016, 1, 1)
     with mock.patch('ievv_opensource.ievv_batchframework.models.timezone.now', lambda: mocknow):
         batchoperation.finish(failed=True)
     self.assertEqual(BatchOperation.RESULT_FAILED, batchoperation.result)
     self.assertEqual('', batchoperation.output_data_json)
     self.assertEqual(batchoperation.finished_datetime, mocknow)
Esempio n. 5
0
 def test_mark_as_running(self):
     batchoperation = mommy.prepare('ievv_batchframework.BatchOperation',
                                    status=BatchOperation.STATUS_UNPROCESSED,
                                    started_running_datetime=None)
     mocknow = datetimeutils.default_timezone_datetime(2016, 1, 1)
     with mock.patch('ievv_opensource.ievv_batchframework.models.timezone.now', lambda: mocknow):
         batchoperation.mark_as_running()
     self.assertEqual(BatchOperation.STATUS_RUNNING,
                      batchoperation.status)
     self.assertEqual(batchoperation.started_running_datetime, mocknow)
 def test_is_in_virtualenv_true(self):
     with mock.patch('ievv_opensource.utils.virtualenvutils.sys.real_prefix',
                     '/something'):
         self.assertTrue(virtualenvutils.is_in_virtualenv())
 def test_get_virtualenv_directory_not_in_virtualenv(self):
     class NoAttributes:
         pass
     with mock.patch('ievv_opensource.utils.virtualenvutils.sys', NoAttributes):
         with self.assertRaises(OSError):
             virtualenvutils.get_virtualenv_directory()
 def test_is_in_virtualenv_false(self):
     class NoAttributes:
         pass
     with mock.patch('ievv_opensource.utils.virtualenvutils.sys', NoAttributes):
         self.assertFalse(virtualenvutils.is_in_virtualenv())