예제 #1
0
 def setUp(self):
     self.trek = TrekFactory.create()
     self.information_desk1 = InformationDeskFactory.create()
     self.information_desk2 = InformationDeskFactory.create(photo=None)
     self.information_desk3 = InformationDeskFactory.create()
     self.trek.information_desks.add(self.information_desk1)
     self.trek.information_desks.add(self.information_desk2)
     self.url = reverse('trekking:trek_information_desk_geojson', kwargs={'pk': self.trek.pk})
예제 #2
0
 def setUp(self):
     self.trek = TrekFactory.create()
     self.information_desk1 = InformationDeskFactory.create()
     self.information_desk2 = InformationDeskFactory.create(photo=None)
     self.information_desk3 = InformationDeskFactory.create()
     self.trek.information_desks.add(self.information_desk1)
     self.trek.information_desks.add(self.information_desk2)
     self.url = reverse('trekking:trek_information_desk_geojson',
                        kwargs={'pk': self.trek.pk})
예제 #3
0
    def test_json_detail(self):
        trek = TrekFactory.create()
        self.information_desk = InformationDeskFactory.create()
        trek.information_desks.add(self.information_desk)

        url = reverse('trekking:trek_json_detail', kwargs={'pk': trek.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        detailjson = json.loads(response.content)
        self.assertDictEqual(detailjson['route'],
                             {"id": trek.route.id,
                              "pictogram": None,
                              "label": trek.route.route})
        self.assertDictEqual(detailjson['difficulty'],
                             {"id": trek.difficulty.id,
                              "pictogram": os.path.join(settings.MEDIA_URL, trek.difficulty.pictogram.name),
                              "label": trek.difficulty.difficulty})
        self.assertDictEqual(detailjson['information_desk'],
                             detailjson['information_desks'][0])
        self.assertDictEqual(detailjson['information_desks'][0],
                             {u'description': u'<p>description 0</p>',
                              u'email': u'*****@*****.**',
                              u'latitude': -5.983593666147552,
                              u'longitude': -1.3630761286186646,
                              u'name': u'information desk name 0',
                              u'phone': u'01 02 03 0',
                              u'photo_url': self.information_desk.photo_url,
                              u'postal_code': 28300,
                              u'street': u'0 baker street',
                              u'municipality': u"Bailleau L'évêque-0",
                              u'website': u'http://makina-corpus.com/0'})
        self.assertEqual(detailjson['information_desk_layer'],
                         '/api/trek/%s/information_desks.geojson' % trek.pk)
        self.assertEqual(detailjson['filelist_url'],
                         '/paperclip/get/trekking/trek/%s/' % trek.pk)
예제 #4
0
    def get_good_data(self):
        path = PathFactory.create()
        return {
            'name_fr': 'Huhu',
            'name_en': 'Hehe',
            'departure_fr': '',
            'departure_en': '',
            'arrival_fr': '',
            'arrival_en': '',
            'published': '',
            'difficulty': '',
            'route': '',
            'description_teaser_fr': '',
            'description_teaser_en': '',
            'description_fr': '',
            'description_en': '',
            'ambiance_fr': '',
            'ambiance_en': '',
            'access_fr': '',
            'access_en': '',
            'disabled_infrastructure_fr': '',
            'disabled_infrastructure_en': '',
            'duration': '0',
            'is_park_centered': '',
            'advised_parking': 'Very close',
            'parking_location': 'POINT (1.0 1.0)',
            'public_transport': 'huhu',
            'advice_fr': '',
            'advice_en': '',
            'themes': ThemeFactory.create().pk,
            'networks': TrekNetworkFactory.create().pk,
            'usages': UsageFactory.create().pk,
            'web_links': WebLinkFactory.create().pk,
            'information_desks': InformationDeskFactory.create().pk,
            'topology': '{"paths": [%s]}' % path.pk,

            'trek_relationship_a-TOTAL_FORMS': '2',
            'trek_relationship_a-INITIAL_FORMS': '0',
            'trek_relationship_a-MAX_NUM_FORMS': '',

            'trek_relationship_a-0-id': '',
            'trek_relationship_a-0-trek_b': TrekFactory.create().pk,
            'trek_relationship_a-0-has_common_edge': 'on',
            'trek_relationship_a-0-has_common_departure': 'on',
            'trek_relationship_a-0-is_circuit_step': '',

            'trek_relationship_a-1-id': '',
            'trek_relationship_a-1-trek_b': TrekFactory.create().pk,
            'trek_relationship_a-1-has_common_edge': '',
            'trek_relationship_a-1-has_common_departure': '',
            'trek_relationship_a-1-is_circuit_step': 'on',
        }
예제 #5
0
 def get_good_data(self):
     path = PathFactory.create()
     return {
         'name_fr': 'Huhu',
         'name_en': 'Hehe',
         'departure_fr': '',
         'departure_en': '',
         'arrival_fr': '',
         'arrival_en': '',
         'published': '',
         'difficulty': '',
         'route': '',
         'description_teaser_fr': '',
         'description_teaser_en': '',
         'description_fr': '',
         'description_en': '',
         'ambiance_fr': '',
         'ambiance_en': '',
         'access_fr': '',
         'access_en': '',
         'disabled_infrastructure_fr': '',
         'disabled_infrastructure_en': '',
         'duration': '0',
         'is_park_centered': '',
         'advised_parking': 'Very close',
         'parking_location': 'POINT (1.0 1.0)',
         'public_transport': 'huhu',
         'advice_fr': '',
         'advice_en': '',
         'themes': ThemeFactory.create().pk,
         'networks': TrekNetworkFactory.create().pk,
         'usages': UsageFactory.create().pk,
         'web_links': WebLinkFactory.create().pk,
         'information_desks': InformationDeskFactory.create().pk,
         'topology': '{"paths": [%s]}' % path.pk,
         'trek_relationship_a-TOTAL_FORMS': '2',
         'trek_relationship_a-INITIAL_FORMS': '0',
         'trek_relationship_a-MAX_NUM_FORMS': '',
         'trek_relationship_a-0-id': '',
         'trek_relationship_a-0-trek_b': TrekFactory.create().pk,
         'trek_relationship_a-0-has_common_edge': 'on',
         'trek_relationship_a-0-has_common_departure': 'on',
         'trek_relationship_a-0-is_circuit_step': '',
         'trek_relationship_a-1-id': '',
         'trek_relationship_a-1-trek_b': TrekFactory.create().pk,
         'trek_relationship_a-1-has_common_edge': '',
         'trek_relationship_a-1-has_common_departure': '',
         'trek_relationship_a-1-is_circuit_step': 'on',
     }
예제 #6
0
    def test_json_detail(self):
        trek = TrekFactory.create()
        self.information_desk = InformationDeskFactory.create()
        trek.information_desks.add(self.information_desk)

        url = reverse('trekking:trek_json_detail', kwargs={'pk': trek.pk})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        detailjson = json.loads(response.content)
        self.assertDictEqual(detailjson['route'], {
            "id": trek.route.id,
            "pictogram": None,
            "label": trek.route.route
        })
        self.assertDictEqual(
            detailjson['difficulty'], {
                "id":
                trek.difficulty.id,
                "pictogram":
                os.path.join(settings.MEDIA_URL,
                             trek.difficulty.pictogram.name),
                "label":
                trek.difficulty.difficulty
            })
        self.assertDictEqual(detailjson['information_desk'],
                             detailjson['information_desks'][0])
        self.assertDictEqual(
            detailjson['information_desks'][0], {
                u'description': u'<p>description 0</p>',
                u'email': u'*****@*****.**',
                u'latitude': -5.983593666147552,
                u'longitude': -1.3630761286186646,
                u'name': u'information desk name 0',
                u'phone': u'01 02 03 0',
                u'photo_url': self.information_desk.photo_url,
                u'postal_code': u'28300',
                u'street': u'0 baker street',
                u'municipality': u"Bailleau L'évêque-0",
                u'website': u'http://makina-corpus.com/0'
            })
        self.assertEqual(detailjson['information_desk_layer'],
                         '/api/trek/%s/information_desks.geojson' % trek.pk)
        self.assertEqual(detailjson['filelist_url'],
                         '/paperclip/get/trekking/trek/%s/' % trek.pk)