コード例 #1
0
ファイル: happy.py プロジェクト: CIRB/cirb.novac
    def get_pub_waws(self):
        url ="%s%s" % (GEOSERVER_PROD, PUBLIC_IDS)
            
        json_from_ws = called_url(url,"")
        if not json_from_ws:
            status = "ko"
            message = "Not able to call GEOSERVER : %s" % url
            return {'status':status, 'message':message}

        dict_ids = json_processing(json_from_ws)
        if not dict_ids: 
            status = "ko"
            message= "Not able to use json from GEOSERVER"
            return {'status':status, 'message':message}

        features = dict_ids.get('features')
        ids = []
        for dossier in features:
            ids.append(dossier.get('id').split('.')[1])
 
        id_dossier = ids[0]

        url = '%s/%s/%s' % (self.novac_url, PUB_DOSSIER, id_dossier)
        results = get_service(url)
        if results.get('status') == 'ko':
            status = results.get('status')
            message = '%s. Access to public dossier %s failled.' % (results.get("message"), id_dossier)
        else:
            status = results.get('status')
            message = 'Access to %s.' % url
        return {'status':status, 'message':message}
コード例 #2
0
ファイル: test_public_view.py プロジェクト: CIRB/cirb.novac
    def test_public_ids(self):
        portal = self.layer["portal"]
        url ="%s%s" % (GEOSERVER_PROD, PUBLIC_IDS)

        json_from_ws = utils.called_url(url,"") 
        self.assertNotEqual(json_from_ws, False, "Not able to call GEOSERVER : %s" % url)
      
        dict_ids = utils.json_processing(json_from_ws)
        self.assertNotEqual(dict_ids, False, "Not able to use json from GEOSERVER")

        features = dict_ids.get('features')
        self.assertEqual(len(features), NUMBER)
        
        for dossier in features:
            self.ids.append(dossier.get('id').split('.')[1])
        self.assertEqual(len(self.ids), NUMBER)

        public_view = publicview.PublicView(portal, "")
        url = "%s/%s/%s" % (public_view.novac_url, publicview.PUB_DOSSIER, self.ids[0])

        json_from_ws = public_view.call_ws(url)
        self.assertNotEqual(json_from_ws, False, "Not able to call WAWS : %s" % url)

        dossier = utils.json_processing(json_from_ws)
        self.assertNotEqual(dossier, False, "Not able to use json from WAWS")

        prop_dossier = dossier.get("properties", None)
        self.assertNotEqual(prop_dossier, None)
        
        streetName = prop_dossier.get("streetName", None)
        self.assertNotEqual(streetName, None)
        
        bad_id_dossier = 14
        url = "%s/%s/%s" % (public_view.novac_url, publicview.PUB_DOSSIER, str(bad_id_dossier))
        self.assertFalse(public_view.call_ws(url))