Test colissimo id lengths, and raise some errors
This commit is contained in:
parent
41278a1d9b
commit
54a16964d4
1 changed files with 5 additions and 2 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.parcel import ICapParcel, Parcel, Event
|
from weboob.capabilities.parcel import ICapParcel, Parcel, Event
|
||||||
|
from weboob.capabilities.base import UserError
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
|
|
||||||
from .browser import ColissimoBrowser
|
from .browser import ColissimoBrowser
|
||||||
|
|
@ -36,12 +37,14 @@ class ColissimoBackend(BaseBackend, ICapParcel):
|
||||||
BROWSER = ColissimoBrowser
|
BROWSER = ColissimoBrowser
|
||||||
|
|
||||||
def get_parcel_tracking(self, _id):
|
def get_parcel_tracking(self, _id):
|
||||||
|
# 13 is the magic length of colissimo tracking ids
|
||||||
|
if len(_id) != 13:
|
||||||
|
raise UserError(u"Colissimo ID's must have 13 print character")
|
||||||
data = self.browser.get_tracking_info(_id)
|
data = self.browser.get_tracking_info(_id)
|
||||||
p = Parcel(_id)
|
p = Parcel(_id)
|
||||||
label = data['message']
|
label = data['message']
|
||||||
if data['error']:
|
if data['error']:
|
||||||
p.info = label
|
raise UserError(u"label")
|
||||||
return p
|
|
||||||
p.info = label
|
p.info = label
|
||||||
# TODO, need to know the delivery message
|
# TODO, need to know the delivery message
|
||||||
if u"remis au gardien ou" in label or u"Votre colis est livré" in label:
|
if u"remis au gardien ou" in label or u"Votre colis est livré" in label:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue