예제 #1
0
 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()
예제 #2
0
 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)))
예제 #3
0
 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)
예제 #4
0
    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'
예제 #5
0
 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)