def test_sync(self): source_a = RecordSourceFactory(name='Source A') source_b = RecordSourceFactory(name='Source B') factory(TouristicContentFactory, source_a) factory(TouristicContentFactory, source_b) factory(TouristicEventFactory, source_a) factory(TouristicEventFactory, source_b) management.call_command('sync_rando', settings.SYNC_RANDO_ROOT, url='http://localhost:8000', source='Source A', skip_tiles=True, verbosity='0') with open( os.path.join(settings.SYNC_RANDO_ROOT, 'api', 'en', 'touristiccontents.geojson'), 'r') as f: tcontents = json.load(f) self.assertEquals(len(tcontents['features']), 1) with open( os.path.join(settings.SYNC_RANDO_ROOT, 'api', 'en', 'touristicevents.geojson'), 'r') as f: tevents = json.load(f) self.assertEquals(len(tevents['features']), 1) with open( os.path.join(settings.SYNC_RANDO_ROOT, 'api', 'en', 'touristiccategories.json'), 'r') as f: tevents = json.load(f) self.assertEquals(len(tevents), 2)
def test_create_event_apidae_constant_fields(self, mocked): def mocked_json(): filename = os.path.join(os.path.dirname(__file__), 'data', 'apidaeEvent.json') with open(filename, 'r') as f: return json.load(f) mocked.return_value.status_code = 200 mocked.return_value.json = mocked_json mocked.return_value.content = b'Fake image' FileType.objects.create(type="Photographie") TargetPortalFactory(name='Portal 1') TargetPortalFactory(name='Portal 2') RecordSourceFactory(name='Source 1') RecordSourceFactory(name='Source 2') self.assertEqual(TouristicEvent.objects.count(), 0) output = io.StringIO() call_command( 'import', 'geotrek.tourism.tests.test_parsers.ApidaeConstantFieldEventParser', verbosity=2, stdout=output) self.assertEqual(TouristicEvent.objects.count(), 1) event = TouristicEvent.objects.get() self.assertEqual(str(event.type), "Constant Event") self.assertQuerysetEqual(event.themes.all(), ["Theme 1", "Theme 2"], transform=str) self.assertQuerysetEqual(event.source.all(), ["Source 1", "Source 2"], transform=str) self.assertQuerysetEqual(event.portal.all(), ["Portal 1", "Portal 2"], transform=str)
def setUp(self): self.contents = [] self.events = [] self.portals = [] self.portal_a = TargetPortalFactory() self.portal_b = TargetPortalFactory() self.source_a = RecordSourceFactory() self.source_b = RecordSourceFactory() self.content_1 = TouristicContentFactory.create( portals=(self.portal_a, self.portal_b), sources=(self.source_a, self.source_b)) self.content_2 = TouristicContentFactory.create( portals=(self.portal_a, ), sources=(self.source_a, self.source_b)) self.event_1 = TouristicEventFactory.create(portals=(self.portal_a, self.portal_b), sources=(self.source_b, )) self.event_2 = TouristicEventFactory.create(portals=(self.portal_b, ), sources=(self.source_a, self.source_b))
def setUpClass(cls): cls.source_a = RecordSourceFactory() cls.source_b = RecordSourceFactory() cls.portal_a = TargetPortalFactory() cls.portal_b = TargetPortalFactory() FlatPageFactory.create(published=True, sources=(cls.source_a, )) FlatPageFactory.create(portals=(cls.portal_a, cls.portal_b), published=True) FlatPageFactory.create(published=True, sources=(cls.source_b, )) FlatPageFactory.create(portals=(cls.portal_a, ), published=True)
def setUp(self): self.source_a = RecordSourceFactory() self.source_b = RecordSourceFactory() self.portal_a = TargetPortalFactory() self.portal_b = TargetPortalFactory() information_desks = InformationDeskFactory.create() self.trek_1 = TrekWithPublishedPOIsFactory.create( sources=(self.source_a, ), portals=(self.portal_b, ), published=True) self.trek_1.information_desks.add(information_desks) self.attachment_1 = AttachmentFactory.create( content_object=self.trek_1, attachment_file=get_dummy_uploaded_image()) self.trek_2 = TrekFactory.create(sources=(self.source_b, ), published=True) self.trek_3 = TrekFactory.create(portals=(self.portal_b, self.portal_a), published=True) self.trek_4 = TrekFactory.create(portals=(self.portal_a, ), published=True) self.poi_1 = trek_models.POI.objects.first() self.attachment_poi_image_1 = AttachmentFactory.create( content_object=self.poi_1, attachment_file=get_dummy_uploaded_image()) self.attachment_poi_image_2 = AttachmentFactory.create( content_object=self.poi_1, attachment_file=get_dummy_uploaded_image()) self.attachment_poi_file = AttachmentFactory.create( content_object=self.poi_1, attachment_file=get_dummy_uploaded_file()) infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1") infrastructure.add_path(self.trek_1.paths.first(), start=0, end=0) signage = SignageFactory.create(no_path=True, name="SIGNA_1") signage.add_path(self.trek_1.paths.first(), start=0, end=0) SensitiveAreaFactory.create(published=True) self.touristic_content = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) self.touristic_event = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) self.attachment_touristic_content = AttachmentFactory.create( content_object=self.touristic_content, attachment_file=get_dummy_uploaded_image()) self.attachment_touristic_event = AttachmentFactory.create( content_object=self.touristic_event, attachment_file=get_dummy_uploaded_image())
def test_sync(self): source_a = RecordSourceFactory(name='Source A') source_b = RecordSourceFactory(name='Source B') factory(FlatPageFactory, source_a) factory(FlatPageFactory, source_b) management.call_command('sync_rando', settings.SYNC_RANDO_ROOT, url='http://localhost:8000', source='Source A', skip_tiles=True, verbosity='0') with open( os.path.join(settings.SYNC_RANDO_ROOT, 'api', 'en', 'flatpages.geojson'), 'r') as f: flatpages = json.load(f) self.assertEquals(len(flatpages), 1)
def test_tiles_with_treks_source_portal(self, mock_tileslist, mock_tiles, mock_prepare): output = StringIO() self.source = RecordSourceFactory() self.portal = TargetPortalFactory() trek = TrekFactory.create(published=True, sources=(self.source, ), portals=(self.portal, )) management.call_command('sync_rando', os.path.join('var', 'tmp'), url='http://localhost:8000', source=self.source.name, portal=self.portal.name, languages='fr', verbosity=2, stdout=output, stderr=StringIO()) zfile = zipfile.ZipFile( os.path.join('var', 'tmp', 'zip', 'tiles', 'global.zip')) for finfo in zfile.infolist(): ifile = zfile.open(finfo) self.assertEqual(ifile.read(), b'I am a png') self.assertIn("zip/tiles/global.zip", output.getvalue()) zfile_trek = zipfile.ZipFile( os.path.join('var', 'tmp', 'zip', 'tiles', '{pk}.zip'.format(pk=trek.pk))) for finfo in zfile_trek.infolist(): ifile_trek = zfile_trek.open(finfo) self.assertEqual(ifile_trek.read(), b'I am a png') self.assertIn("zip/tiles/{pk}.zip".format(pk=trek.pk), output.getvalue())
def setUpClass(cls): super(SyncMobileFlatpageTest, cls).setUpClass() translation.deactivate() cls.portals = [] cls.portal_a = TargetPortalFactory() cls.portal_b = TargetPortalFactory() cls.source_a = RecordSourceFactory() cls.source_b = RecordSourceFactory() FlatPageFactory.create(published=True) FlatPageFactory.create(portals=(cls.portal_a, cls.portal_b), published=True) FlatPageFactory.create(published=True) FlatPageFactory.create(portals=(cls.portal_a, ), published=True)
def setUpClass(cls): super(SyncRandoTestCase, cls).setUpClass() cls.trek = TrekWithPublishedPOIsFactory.create(published=True) cls.information_desks = InformationDeskFactory.create() cls.trek.information_desks.add(cls.information_desks) cls.attachment = AttachmentFactory.create( content_object=cls.trek, attachment_file=get_dummy_uploaded_image()) cls.source_a = RecordSourceFactory() cls.source_b = RecordSourceFactory() cls.portal_a = TargetPortalFactory() cls.portal_b = TargetPortalFactory() cls.trek_fr = TrekFactory.create(published_fr=True, sources=(cls.source_b, )) cls.trek_sb = TrekFactory.create(sources=(cls.source_b, ), published=True) cls.trek_sb_pa = TrekFactory.create(sources=(cls.source_b, ), portals=(cls.portal_a, ), published=True) cls.touristic_content = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.touristic_event = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.attachment_touristic_content = AttachmentFactory.create( content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) cls.attachment_touristic_event = AttachmentFactory.create( content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image()) cls.poi = trek_models.POI.objects.first() cls.attachment_poi_image = AttachmentFactory.create( content_object=cls.poi, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.poi, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.poi, attachment_file=get_dummy_uploaded_file())
def setUp(self): self.source_a = RecordSourceFactory() self.source_b = RecordSourceFactory() self.portal_a = TargetPortalFactory() self.portal_b = TargetPortalFactory() self.trek_1 = TrekFactory.create(sources=(self.source_a, ), portals=(self.portal_b, ), published=True) self.trek_2 = TrekFactory.create(sources=(self.source_b, ), published=True) self.trek_3 = TrekFactory.create(portals=(self.portal_b, self.portal_a), published=True) self.trek_4 = TrekFactory.create(portals=(self.portal_a, ), published=True)
def setUpClass(cls): super(SyncRandoTestCase, cls).setUpClass() cls.practice_dive = PracticeFactory.create(order=0) cls.dive = DiveFactory.create(practice=cls.practice_dive, published=True, geom='SRID=2154;POINT(700001 6600001)') cls.attachment_dive = AttachmentFactory.create(content_object=cls.dive, attachment_file=get_dummy_uploaded_image()) cls.poi_dive = POIFactory.create(name="dive_poi", published=True) AttachmentFactory.create(content_object=cls.poi_dive, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.poi_dive, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.poi_dive, attachment_file=get_dummy_uploaded_file()) cls.touristic_content = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.touristic_event = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.attachment_touristic_content = AttachmentFactory.create(content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) cls.attachment_touristic_event = AttachmentFactory.create(content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image()) cls.source_a = RecordSourceFactory() cls.source_b = RecordSourceFactory() cls.portal_a = TargetPortalFactory() cls.portal_b = TargetPortalFactory() cls.dive_portal_source = DiveFactory.create(practice=cls.practice_dive, published=True, geom='SRID=2154;POINT(700002 6600002)', portals=(cls.portal_a,), sources=(cls.source_a,)) cls.dive_other_portal_source = DiveFactory.create(practice=cls.practice_dive, published=True, geom='SRID=2154;POINT(700002 6600002)', portals=(cls.portal_b,), sources=(cls.source_b,))
def test_create_event_tourinsoft(self, mocked): def mocked_json(): filename = os.path.join(os.path.dirname(__file__), 'data', 'tourinsoftEvent.json') with open(filename, 'r') as f: return json.load(f) mocked.return_value.status_code = 200 mocked.return_value.json = mocked_json mocked.return_value.content = b'Fake image' FileType.objects.create(type="Photographie") type = TouristicEventTypeFactory(type="Agenda rando") source = RecordSourceFactory(name="CDT 28") portal = TargetPortalFactory(name="Itinérance") call_command('import', 'geotrek.tourism.tests.test_parsers.FMA28', verbosity=0) self.assertEqual(TouristicEvent.objects.count(), 1) event = TouristicEvent.objects.get() self.assertEqual(event.eid, "FMACEN0280060359") self.assertEqual(event.name, "Moto cross de Brou") self.assertEqual(event.description, "") self.assertEqual(event.description_teaser, "") self.assertEqual( event.contact[:69], "<strong>Adresse :</strong><br>Circuit des Tonnes<br>28160 DAMPIERRE-S" ) self.assertEqual(event.email, "*****@*****.**") self.assertEqual(event.website, "http://www.mxbrou.com") self.assertEqual(round(event.geom.x), 559796) self.assertEqual(round(event.geom.y), 6791765) self.assertEqual( event.practical_info[:61], "<strong>Langues parlées :</strong><br>Anglais<br>Allemand<br>") self.assertIn( "<strong>Équipements :</strong><br>Restauration sur place<br>Sanitaires", event.practical_info) self.assertTrue(event.published) self.assertEqual(event.source.get(), source) self.assertEqual(event.portal.get(), portal) self.assertEqual(event.type, type) self.assertEqual(Attachment.objects.count(), 9) self.assertEqual(Attachment.objects.first().content_object, event) self.assertEqual(event.begin_date, date(2100, 6, 1)) self.assertEqual(event.end_date, date(2100, 6, 2))
def test_create_content_tourinsoft_v3(self, mocked): def mocked_json(): filename = os.path.join(os.path.dirname(__file__), 'data', 'tourinsoftContentV3.json') with open(filename, 'r') as f: return json.load(f) mocked.return_value.status_code = 200 mocked.return_value.json = mocked_json mocked.return_value.content = b'Fake image' FileType.objects.create(type="Photographie") category = TouristicContentCategoryFactory(label="Où dormir") source = RecordSourceFactory(name="CDT 28") portal = TargetPortalFactory(name="Itinérance") call_command('import', 'geotrek.tourism.tests.test_parsers.HOT28v3', verbosity=0) self.assertEqual(TouristicContent.objects.count(), 1) content = TouristicContent.objects.get() self.assertEqual(content.eid, "HOTCEN0280010001") self.assertEqual(content.name, "Hôtel du Perche") self.assertEqual(content.description[:27], "") self.assertEqual(content.description_teaser[:26], "A deux pas du centre ville") self.assertEqual( content.contact[:73], "<strong>Adresse :</strong><br>Rue de la Bruyère<br>28400 NOGENT-LE-ROTROU" ) self.assertEqual(content.email, "*****@*****.**") self.assertEqual(content.website, "http://www.hotel-du-perche.com") self.assertEqual(round(content.geom.x), 537329) self.assertEqual(round(content.geom.y), 6805504) self.assertEqual(content.practical_info[:49], "<strong>Langues parlées :</strong><br>Anglais<br>") self.assertIn("du 01/01/2019 au 21/07/2019", content.practical_info) self.assertIn("<strong>Équipements :</strong><br>Bar<br>Parking<br>", content.practical_info) self.assertTrue(content.published) self.assertEqual(content.source.get(), source) self.assertEqual(content.portal.get(), portal) self.assertEqual(content.category, category) self.assertEqual(content.type1.get().label, "Hôtels") self.assertEqual(content.type2.get().label, "****") self.assertEqual(Attachment.objects.count(), 3) self.assertEqual(Attachment.objects.first().content_object, content)
def setUpClass(cls): super(SyncRandoTestCase, cls).setUpClass() cls.source = RecordSourceFactory() cls.portal = TargetPortalFactory() cls.information_desks = InformationDeskFactory.create() cls.touristic_content = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.touristic_event = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) cls.attachment_touristic_content = AttachmentFactory.create(content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) cls.attachment_touristic_event = AttachmentFactory.create(content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_content, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=cls.touristic_event, attachment_file=get_dummy_uploaded_image())
def test_api_filters(self): SiteFactory.create(name='site1', published=False) SiteFactory.create(name='site2', published=True) site3 = SiteFactory.create(name='site3', published=True) site3.source.add(RecordSourceFactory.create(name='source1')) site3.portal.add(TargetPortalFactory.create(name='portal1')) response1 = self.client.get('/api/en/sites.json') self.assertEqual(len(response1.json()), 2) self.assertEqual(set((site['name'] for site in response1.json())), set(('site2', 'site3'))) response2 = self.client.get('/api/en/sites.json?source=source1') self.assertEqual(len(response2.json()), 1) self.assertEqual(response2.json()[0]['name'], 'site3') response3 = self.client.get('/api/en/sites.json?portal=portal1') self.assertEqual(len(response3.json()), 2) self.assertEqual(set((site['name'] for site in response3.json())), set(('site2', 'site3'))) response4 = self.client.get('/api/en/sites.json?portal=portalX') self.assertEqual(len(response4.json()), 1) self.assertEqual(response4.json()[0]['name'], 'site2')
def setUp(self): self.source_a = RecordSourceFactory() self.source_b = RecordSourceFactory() self.portal_a = TargetPortalFactory() self.portal_b = TargetPortalFactory() information_desks = InformationDeskFactory.create() self.practice_trek = PracticeTrekFactory.create(order=1) self.practice_trek_first = PracticeTrekFactory.create(order=0) self.trek_1 = TrekWithPublishedPOIsFactory.create(practice=self.practice_trek, sources=(self.source_a, ), portals=(self.portal_b,), published=True) self.trek_1.information_desks.add(information_desks) self.attachment_1 = AttachmentFactory.create(content_object=self.trek_1, attachment_file=get_dummy_uploaded_image()) self.trek_2 = TrekFactory.create(sources=(self.source_b,), published=True) self.trek_3 = TrekFactory.create(portals=(self.portal_b, self.portal_a), published=True) self.trek_4 = TrekFactory.create(practice=self.practice_trek, portals=(self.portal_a,), published=True) self.trek_5 = TrekFactory.create(practice=self.practice_trek_first, portals=(self.portal_a,), published=True, name="other") self.practice_dive = PracticeDiveFactory.create(order=0) self.dive_1 = DiveFactory.create(practice=self.practice_dive, sources=(self.source_a,), portals=(self.portal_b,), published=True, geom='SRID=2154;POINT(700001 6600001)') self.attachment_dive = AttachmentFactory.create(content_object=self.dive_1, attachment_file=get_dummy_uploaded_image()) self.dive_2 = DiveFactory.create(sources=(self.source_b,), published=True, geom='SRID=2154;LINESTRING (700000 6600000, 700100 6600100)') self.dive_3 = DiveFactory.create(portals=(self.portal_b, self.portal_a), published=True, geom='POLYGON((700000 6600000, 700000 6600100, ' '700100 6600100, 700100 6600000, 700000 6600000))') self.dive_4 = DiveFactory.create(practice=self.practice_dive, portals=(self.portal_a,), published=True) self.poi_1 = trek_models.POI.objects.first() self.poi_dive = POIFactory.create(name="dive_poi", published=True) self.attachment_poi_image_1 = AttachmentFactory.create(content_object=self.poi_1, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=self.poi_dive, attachment_file=get_dummy_uploaded_image()) self.attachment_poi_image_2 = AttachmentFactory.create(content_object=self.poi_1, attachment_file=get_dummy_uploaded_image()) AttachmentFactory.create(content_object=self.poi_dive, attachment_file=get_dummy_uploaded_file()) self.attachment_poi_file = AttachmentFactory.create(content_object=self.poi_1, attachment_file=get_dummy_uploaded_file()) if settings.TREKKING_TOPOLOGY_ENABLED: infrastructure = InfrastructureFactory.create(no_path=True, name="INFRA_1") infrastructure.add_path(self.trek_1.paths.first(), start=0, end=0) signage = SignageFactory.create(no_path=True, name="SIGNA_1") signage.add_path(self.trek_1.paths.first(), start=0, end=0) else: InfrastructureFactory.create(geom='SRID=2154;POINT(700000 6600000)', name="INFRA_1") SignageFactory.create(geom='SRID=2154;POINT(700000 6600000)', name="SIGNA_1") area = SensitiveAreaFactory.create(published=True) area.species.practices.add(SportPracticeFactory.create(name='Terrestre')) area.save() self.touristic_content = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) self.touristic_event = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, published=True) self.attachment_touristic_content = AttachmentFactory.create(content_object=self.touristic_content, attachment_file=get_dummy_uploaded_image()) self.attachment_touristic_event = AttachmentFactory.create(content_object=self.touristic_event, attachment_file=get_dummy_uploaded_image())
def setUp(self): self.login() polygon = 'SRID=%s;MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0)))' % settings.SRID self.city = CityFactory(geom=polygon) self.district = DistrictFactory(geom=polygon) self.parent = TrekFactory.create(published=True) self.trek = TrekFactory.create( parent=self.parent, no_path=True, points_reference=MultiPoint([Point(0, 0), Point(1, 1)], srid=settings.SRID), parking_location=Point(0, 0, srid=settings.SRID) ) path1 = PathFactory.create(geom='SRID=%s;LINESTRING(0 0, 1 0)' % settings.SRID) self.trek.add_path(path1) self.attachment = AttachmentFactory.create(obj=self.trek, attachment_file=get_dummy_uploaded_image()) self.information_desk = tourism_factories.InformationDeskFactory.create() self.trek.information_desks.add(self.information_desk) self.theme = ThemeFactory.create() self.trek.themes.add(self.theme) self.accessibility = AccessibilityFactory.create() self.trek.accessibilities.add(self.accessibility) self.network = TrekNetworkFactory.create() self.trek.networks.add(self.network) self.weblink = WebLinkFactory.create() self.trek.web_links.add(self.weblink) self.source = RecordSourceFactory.create() self.trek.source.add(self.source) self.trek_b = TrekFactory.create(no_path=True, geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True) path2 = PathFactory.create(geom='SRID=%s;LINESTRING(0 1, 1 1)' % settings.SRID) self.trek_b.add_path(path2) TrekRelationshipFactory.create(has_common_departure=True, has_common_edge=False, is_circuit_step=True, trek_a=self.trek, trek_b=self.trek_b) self.touristic_content = tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True) tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=False) # not published tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1 1)' % settings.SRID, published=True).delete() # deleted tourism_factories.TouristicContentFactory(geom='SRID=%s;POINT(1000 1000)' % settings.SRID, published=True) # too far self.touristic_event = tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True) tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=False) # not published tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2 2)' % settings.SRID, published=True).delete() # deleted tourism_factories.TouristicEventFactory(geom='SRID=%s;POINT(2000 2000)' % settings.SRID, published=True) # too far trek2 = TrekFactory(no_path=True, published=False) # not published trek2.add_path(path2) trek3 = TrekFactory(no_path=True, published=True) # deleted trek3.add_path(path2) trek3.delete() trek4 = TrekFactory(no_path=True, published=True) # too far trek4.add_path(PathFactory.create(geom='SRID=%s;LINESTRING(0 2000, 1 2000)' % settings.SRID)) self.child1 = TrekFactory.create(published=False, parent=self.trek) self.child2 = TrekFactory.create(published=True, parent=self.trek) self.pk = self.trek.pk url = '/api/treks/%s/' % self.pk self.response = self.client.get(url) self.result = json.loads(self.response.content)