File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ import bottle
2+ import json
13from bottle import route , run , response
24from CepTracker import CepTracker
35from requests import ConnectionError
46from correios import Correios
57
68from database import MongoDb as Database
79
8- import json
10+ app_v1 = bottle . Bottle ()
911
1012def expired (record_date ):
1113 from datetime import datetime , timedelta
@@ -28,6 +30,7 @@ def _get_info_from_source(cep):
2830
2931
3032@route ('/cep/<cep:re:\d{5}-?\d{3}>' )
33+ @app_v1 .route ('/cep/<cep:re:\d{5}-?\d{3}>' )
3134def verifica_cep (cep ):
3235 cep = cep .replace ('-' ,'' )
3336 db = Database ()
@@ -54,6 +57,7 @@ def verifica_cep(cep):
5457
5558 return result
5659
60+
5761@route ('/track/ect/<track>' )
5862def track_ect (track ):
5963 try :
@@ -76,5 +80,8 @@ def track_ect(track):
7680 except AttributeError :
7781 response .status = '404 O pacote %s informado nao pode ser localizado'
7882
83+
84+ bottle .mount ('/v1' , app_v1 )
85+
7986def _standalone (port = 9876 ):
8087 run (host = 'localhost' , port = port )
Original file line number Diff line number Diff line change @@ -113,3 +113,13 @@ def assertCep(self, cep):
113113 self .assertEqual (v , result [k ])
114114
115115 self .assertNotIn ('v_date' , result )
116+
117+ class PostmonV1WebTest (PostmonWebTest ):
118+
119+ '''
120+ Teste do servidor do Postmon no /v1
121+ '''
122+
123+ def get_cep (self , cep ):
124+ response = self .app .get ('/v1/cep/' + cep )
125+ return response .json
You can’t perform that action at this time.
0 commit comments