Esempio n. 1
0
    def test_find_operation_unknown_operation(self):
        """
        Tests find_operation returns None when the operation name is not
        registered
        """
        def myop(backend):
            pass

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

        self.assertIsNone(Image.find_operation('test2'))
Esempio n. 2
0
    def test_find_operation_unknown_operation(self):
        """
        Tests find_operation returns None when the operation name is not
        registered
        """
        def myop(backend):
            pass

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

        self.assertIsNone(Image.find_operation('test2'))
Esempio n. 3
0
    def test_find_operation(self):
        """
        Tests basic usage of find_operation
        """
        def myop(backend):
            pass

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

        self.assertEqual(Image.find_operation('test'), (
            self.FakeBackend,
            myop,
        ))
Esempio n. 4
0
    def test_find_operation(self):
        """
        Tests basic usage of find_operation
        """
        def myop(backend):
            pass

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

        self.assertEqual(Image.find_operation('test'), (
            self.FakeBackend,
            myop,
        ))
Esempio n. 5
0
    def test_find_operation_with_bad_backend(self):
        """
        Tests that find_operation ignores bad backends
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(Image.find_operation('test'), (
            self.AnotherFakeBackend,
            myop,
        ))
Esempio n. 6
0
    def test_find_operation_multiple_backends_preferred(self):
        """
        Tests find_operation will priorities the preferred backend
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(Image.find_operation('test', preferred_backend=self.AnotherFakeBackend), (
            self.AnotherFakeBackend,
            myop,
        ))
Esempio n. 7
0
    def test_find_operation_with_bad_backend(self):
        """
        Tests that find_operation ignores bad backends
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(Image.find_operation('test'), (
            self.AnotherFakeBackend,
            myop,
        ))
Esempio n. 8
0
    def test_find_operation_multiple_backends(self):
        """
        Tests find_operation picks the first available backend if the operation
        has been registered by multiple backends
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(Image.find_operation('test'), (
            self.FakeBackend,
            myop,
        ))
Esempio n. 9
0
    def test_find_operation_multiple_backends(self):
        """
        Tests find_operation picks the first available backend if the operation
        has been registered by multiple backends
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(Image.find_operation('test'), (
            self.FakeBackend,
            myop,
        ))
Esempio n. 10
0
    def test_find_operation_multiple_backends_preferred(self):
        """
        Tests find_operation will priorities the preferred backend
        """
        def myop(backend):
            pass

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

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

        self.assertEqual(
            Image.find_operation('test',
                                 preferred_backend=self.AnotherFakeBackend), (
                                     self.AnotherFakeBackend,
                                     myop,
                                 ))