Esempio n. 1
0
    def test_calls_function(self):
        """
        Tests that calling the operation calls the underlying function
        """
        def myop(backend):
            backend.func_called = True

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')
        image.backend.func_called = False
        image.test()

        self.assertTrue(image.backend.func_called)
Esempio n. 2
0
    def test_calls_function(self):
        """
        Tests that calling the operation calls the underlying function
        """
        def myop(backend):
            backend.func_called = True

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')
        image.backend.func_called = False
        image.test()

        self.assertTrue(image.backend.func_called)
Esempio n. 3
0
    def test_args_get_passed_through(self):
        """
        Tests that args get passed through to the underlying function
        """
        def myop(backend, *args, **kwargs):
            backend.passed_args = args
            backend.passed_kwargs = kwargs

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')
        image.backend.passed_args = None
        image.backend.passed_kwargs = None
        image.test('Hello', 'World', name="Karl")

        self.assertEqual(image.backend.passed_args, ('Hello', 'World'))
        self.assertEqual(image.backend.passed_kwargs, {'name': "Karl"})
Esempio n. 4
0
    def test_args_get_passed_through(self):
        """
        Tests that args get passed through to the underlying function
        """
        def myop(backend, *args, **kwargs):
            backend.passed_args = args
            backend.passed_kwargs = kwargs

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')
        image.backend.passed_args = None
        image.backend.passed_kwargs = None
        image.test('Hello', 'World', name="Karl")

        self.assertEqual(image.backend.passed_args, ('Hello', 'World'))
        self.assertEqual(image.backend.passed_kwargs, {'name': "Karl"})
Esempio n. 5
0
    def test_return_value_gets_passed_back(self):
        """
        Tests that the return value of the underlying function gets passed back
        to the caller
        """
        def myop(backend):
            return "Hello world!"

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')

        self.assertEqual(image.test(), "Hello world!")
Esempio n. 6
0
    def test_return_value_gets_passed_back(self):
        """
        Tests that the return value of the underlying function gets passed back
        to the caller
        """
        def myop(backend):
            return "Hello world!"

        self.FakeBackend.operations = {
            'test': myop,
        }

        image = Image(self.FakeBackend(), 'jpeg')

        self.assertEqual(image.test(), "Hello world!")