def test_get_adapter_for_type_is_available(self): """ Tests that the get_adapter_for_type returns the appropriate adapter if the format type is available. """ disp = FakeDispatcher() disp.register_adapters(SirenAdapter, HalAdapter) adapter = disp.get_adapter_for_type(['application/vnd.siren+json', 'application/hal+json']) self.assertEqual(adapter, SirenAdapter) adapter2 = disp.get_adapter_for_type(['application/hal+json', 'application/vnd.siren+json']) self.assertEqual(adapter2, HalAdapter)
def test_get_adapter_for_type_is_available(self): """ Tests that the get_adapter_for_type returns the appropriate adapter if the format type is available. """ disp = FakeDispatcher() disp.register_adapters(SirenAdapter, HalAdapter) adapter = disp.get_adapter_for_type(['application/vnd.siren+json', 'application/hal+json']) self.assertEqual(adapter, SirenAdapter) adapter2 = disp.get_adapter_for_type(['application/hal+json', 'application/vnd.siren+json']) self.assertEqual(adapter2, HalAdapter)
def test_get_adapter_for_type_not_available(self): """ Tests that the get_adapter_for_type returns the default adapter if None of the accepted mimetypes are available. """ disp = FakeDispatcher() disp.register_adapters(SirenAdapter, HalAdapter) adapter = disp.get_adapter_for_type(['application/json', 'text/html']) self.assertEqual(adapter, SirenAdapter)
def test_get_adapter_for_type_not_available(self): """ Tests that the get_adapter_for_type returns the default adapter if None of the accepted mimetypes are available. """ disp = FakeDispatcher() disp.register_adapters(SirenAdapter, HalAdapter) adapter = disp.get_adapter_for_type(['application/json', 'text/html']) self.assertEqual(adapter, SirenAdapter)