Exemple #1
0
 def test_init_empty_context(self):
     context = {
         "task": mock.MagicMock()
     }
     ctx = fakes.FakeContext(context)
     self.assertEqual(ctx.config, {})
     self.assertEqual(ctx.task, context["task"])
     self.assertEqual(ctx.context, context)
Exemple #2
0
    def test_with_statement(self):
        context = {"task": mock.MagicMock()}
        ctx = fakes.FakeContext(context)
        ctx.setup = mock.MagicMock()
        ctx.cleanup = mock.MagicMock()

        with ctx as entered_ctx:
            self.assertEqual(ctx, entered_ctx)

        ctx.cleanup.assert_called_once_with()
Exemple #3
0
    def test_init(self):
        context = {
            "config": {
                "a": 1,
                "fake": mock.MagicMock()
            },
            "task": mock.MagicMock()
        }

        ctx = fakes.FakeContext(context)
        self.assertEqual(ctx.config, context["config"]["fake"])
        self.assertEqual(ctx.task, context["task"])
        self.assertEqual(ctx.context, context)