def test_as_dict_with_transport_service(self): with mock.patch('moxie.places.representations.TransportService', new=MockTransportServiceNeverProvide): with self.app.blueprint_context('foobar'): poi = HALPOIRepresentation(self.test_poi, 'places.poidetail') poi = poi.as_dict() # Test we don't have any links starting with 'rti:' self.assertFalse(any([link.startswith('rti') for link in poi['_links']]))
def test_as_dict_with_transport_service_provided_multiple_rti(self): with mock.patch('moxie.places.representations.TransportService', new=MockTransportServiceAlwaysProvideMulti): with self.app.blueprint_context('foobar'): poi = HALPOIRepresentation(self.test_poi, 'places.poidetail') poi = poi.as_dict() self.assertTrue('rti:rti1' in poi['_links']) self.assertTrue('rti:rti2' in poi['_links']) self.assertTrue('rti:rti3' in poi['_links'])
def test_as_dict_with_transport_service_rti_titles(self): with mock.patch('moxie.places.representations.TransportService', new=MockTransportServiceAlwaysProvide): with self.app.blueprint_context('foobar'): poi = HALPOIRepresentation(self.test_poi, 'places.poidetail') poi = poi.as_dict() self.assertTrue(poi['_links']['rti:some-fake-rti']['title'] == 'Fake RTI')
def test_as_dict_no_transport_service(self): with self.app.blueprint_context('foobar'): poi = HALPOIRepresentation(self.test_poi, 'places.poidetail') poi = poi.as_dict() self.assertFalse('hl:rti' in poi['_links'])
def test_as_dict_with_many_providers_no_rti(self): with mock.patch('moxie.places.representations.TransportService', new=MockTransportServiceMultipleProviders): with self.app.blueprint_context('foobar'): poi = HALPOIRepresentation(self.test_poi, 'places.poidetail') poi = poi.as_dict() self.assertFalse(any([link.startswith('rti') for link in poi['_links']]))