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'))
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, ))
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, ))
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, ))
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, ))
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, ))