def test_project_stop_aborted(self, get_internal_project: MagicMock): """ Should abort stopping and not raise an error when no internal project is available to stop. """ get_internal_project.return_value = None ep = exposed.ExposedProject() ep.stop()
def test_project_path(self): """Should create an absolute path within the project""" ep = exposed.ExposedProject() project = MagicMock() project.source_directory = os.path.realpath(os.path.dirname(__file__)) ep.load(project) result = ep.path('hello.md') self.assertTrue(result.endswith('{}hello.md'.format(os.sep)))
def test_get_internal_project(self, sleep: MagicMock, internal_project: PropertyMock): """Should get internal project on the third attempt""" project = exposed.ExposedProject() internal_project.side_effect = [None, None, 'test'] result = project.get_internal_project() self.assertEqual('test', result) self.assertEqual(2, sleep.call_count)
def test_no_project_defaults(self): """Expected defaults when no project exists""" ep = exposed.ExposedProject() self.assertIsNone(ep.display) self.assertIsNone(ep.shared) self.assertIsNone(ep.settings) self.assertIsNone(ep.title) self.assertIsNone(ep.id) self.assertIsNone(ep.path()) with self.assertRaises(RuntimeError): ep.title = 'Some Title'
def test_get_internal_project_fail(self, sleep: MagicMock, time_time: MagicMock, internal_project: PropertyMock): """ Should fail to get internal project and return None after eventually timing out. """ project = exposed.ExposedProject() time_time.side_effect = range(20) internal_project.return_value = None result = project.get_internal_project() self.assertIsNone(result) self.assertEqual(10, sleep.call_count)