Esempio n. 1
0
 def test_analysis_old_dni_valid_id_surnames(self):
     parser = DNIScumParser(DNI_OLD_COMPLETE_SURNAMES)
     reference_date = datetime(year=2017, month=11, day=1).date()
     self.assertAnalysis([parser.VALID],
                         parser.analysis(person={'name': 'Jose alberto',
                                                 'surnames': 'Cort\xe9s sanz', 'id': None},
                                         reference_date=reference_date))
Esempio n. 2
0
 def test_analysis_dni_expired(self):
      parser = DNIScumParser(DNI_OLD)
      reference_date = datetime(year=2030, month=11, day=1).date()
      self.assertAnalysis([parser.EXPIRED, parser.FRONT, parser.BACK],
                          parser.analysis(person={'name': 'maria del sagrario',
                                                  'surnames': 'sanchez de la blanca puente', 'id': '56933095f'},
                                          reference_date=reference_date))
Esempio n. 3
0
 def test_analysis_old_dni_valid(self):
      parser = DNIScumParser(DNI_OLD)
      reference_date = datetime(year=2017, month=11, day=1).date()
      self.assertAnalysis([parser.VALID],
                          parser.analysis(person={'name': 'maria del sagrario',
                                                  'surnames': 'sanchez de la blanca puente', 'id': '56933095f'},
                                          reference_date=reference_date))
Esempio n. 4
0
 def test_analysis_old_dni_valid_id_none(self):
     parser = DNIScumParser(DNI_OLD_ALL)
     reference_date = datetime(year=2017, month=11, day=1).date()
     self.assertAnalysis([parser.VALID],
                         parser.analysis(person={'name': 'Clara',
                                                 'surnames': 'Abad', 'id': None},
                                         reference_date=reference_date))
Esempio n. 5
0
 def test_dni_old_first_back_in_same_level(self):
     keywords = dict(self.keywords)
     keywords = {key:False for key, value in self.keywords.items()}
     keywords["idesp"] = True
     keywords['dni num'] = True
     keywords['domicilio / domicili'] = True
     keywords['lugar de nacimiento/ lloc de naixement'] = True
     keywords['equipo / equip'] = True
     parser = DNIScumParser(DNI_OLD_FIRST_BACK)
     result = parser.parse()
     ocrs = {'date_expires': u'210610', 'surnames': u'martinez gago', 'date_birth': u'690619',
             'names': u'pepa esther', 'nat': u'esp', 'country': u'esp', 'dni': u'53686041w', 'sex': u'f'}
     self.assertResult(result, [date(year=1969, month=6, day=19),
                                date(year=2021, month=6, day=10)], keywords, ocrs)
Esempio n. 6
0
 def test_dni_old(self):
     keywords = dict(self.keywords)
     keywords['dni'] = False
     keywords['nombre'] = False
     keywords['apellidos'] = False
     keywords['num soport validez'] = False
     ocrs = {'date_expires': '210919',
             'date_birth': '781009',
             'nat': 'esp',
             'country': 'esp',
             'dni': '56933095f',
             'sex': 'f',
             'surnames': 'sanchoz de la blancakpuente', 'names': 'm'}
     parser = DNIScumParser(DNI_OLD)
     result = parser.parse()
     self.assertResult(result, [date(year=2021, month=9, day=19)], keywords, ocrs)
Esempio n. 7
0
 def test_dni_old_no_back(self):
     keywords = dict(self.keywords)
     keywords['equipo'] = False
     keywords['lugar de nacimiento'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     keywords['nombre'] = False
     keywords['apellidos'] = False
     keywords['hijo/a de'] = False
     keywords['num soport validez'] = False
     keywords['domicilio'] = False
     ocrs = {}
     parser = DNIScumParser(DNI_OLD_NO_BACK)
     result = parser.parse()
     self.assertResult(result, [date(year=2021, month=9, day=19)], keywords, ocrs)
Esempio n. 8
0
 def test_dni_new_no_back_no_correct_dates(self):
     keywords = dict(self.keywords)
     keywords['domicilio'] = False
     keywords['primer apellido'] = False
     keywords['segundo apellido'] = False
     keywords['dni num'] = False
     keywords['valido hasta'] = False
     keywords['lugar de domicilio'] = False
     keywords['hijo/a de'] = False
     keywords['equipo'] = False
     keywords['lugar de nacimiento'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     ocrs = {}
     parser = DNIScumParser(DNI_NEW_NO_BACK_ERROR_DATES)
     result = parser.parse()
     self.assertResult(result, [], keywords, ocrs)
Esempio n. 9
0
 def test_dni_new_no_back(self):
     keywords = dict(self.keywords)
     keywords['domicilio'] = False
     keywords['primer apellido'] = False
     keywords['segundo apellido'] = False
     keywords['dni num'] = False
     keywords['valido hasta'] = False
     keywords['lugar de domicilio'] = False
     keywords['hijo/a de'] = False
     keywords['equipo'] = False
     keywords['lugar de nacimiento'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     ocrs = {}
     parser = DNIScumParser(DNI_NEW_NO_BACK)
     result = parser.parse()
     self.assertResult(result, [date(year=1983, month=11, day=17),
                                date(year=2026, month=4, day=12)], keywords, ocrs)
Esempio n. 10
0
 def test_dni_new(self):
     keywords = dict(self.keywords)
     keywords['domicilio'] = False
     keywords['primer apellido'] = False
     keywords['segundo apellido'] = False
     keywords['dni num'] = False
     keywords['valido hasta'] = False
     keywords['lugar de domicilio'] = False
     keywords['hijo/a de'] = False
     keywords['equipo'] = False
     keywords['lugar de nacimiento'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     ocrs = {'date_expires': u'260412', 'surnames': u'alvarez dorado', 'date_birth': u'831117',
                  'names': u'ramon', 'nat': u'esp', 'country': u'esp', 'dni': u'04900073d', 'sex': u'm'}
     parser = DNIScumParser(DNI_NEW)
     result = parser.parse()
     self.assertResult(result, [date(year=1983, month=11, day=17),
                                date(year=2026, month=4, day=12)], keywords, ocrs)
Esempio n. 11
0
 def test_dni_old_cat(self):
     keywords = self.keywords.copy()
     keywords['segundo apellido'] = False
     keywords['equipo'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     keywords["apellidos"] =  False
     keywords["num soport validez"] = False
     keywords["fecha de nacimiento"] = False
     keywords["sexo nacionalidad"] = False
     keywords["valido hasta"] = False
     keywords["domicilio"] = False
     keywords["idesp"] = False
     keywords["hijo/a de"] = False
     keywords["lugar de nacimiento"] = False
     keywords['nombre'] = False
     keywords['primer apellido'] = False
     ocrs = {'date_expires': u'240123', 'date_birth': u'730116', 'nat': u'esp', 'country': u'esp', 'dni': u'52522003r', 'sex': u'm'}
     parser = DNIScumParser(DNI_OLD_CAT)
     result = parser.parse()
     self.assertResult(result, [date(year=2025, month=1, day=23)], keywords, ocrs)
Esempio n. 12
0
 def test_dni_old_no_back_cat(self):
     keywords = self.keywords.copy()
     keywords['segundo apellido'] = False
     keywords['equipo'] = False
     keywords['lugar de domicilio'] = False
     keywords['dni'] = False
     keywords['provincia/pais'] = False
     keywords["apellidos"] =  False
     keywords["num soport validez"] = False
     keywords["fecha de nacimiento"] = False
     keywords["sexo nacionalidad"] = False
     keywords["valido hasta"] = False
     keywords["domicilio"] = False
     keywords["idesp"] = False
     keywords["hijo/a de"] = False
     keywords["lugar de nacimiento"] = False
     keywords['nombre'] = False
     keywords['primer apellido'] = False
     ocrs = {}
     parser = DNIScumParser(DNI_OLD_NO_BACK_CAT)
     result = parser.parse()
     self.assertResult(result, [date(year=2025, month=1, day=23)], keywords, ocrs)
Esempio n. 13
0
 def test_analysis_not_valid(self):
      parser = DNIScumParser(DNI_NOT_VALID)
      self.assertAnalysis([parser.NOT_VALID], parser.analysis())
Esempio n. 14
0
 def test_is_expired_with_no_back(self):
      parser = DNIScumParser(DNI_NEW_NO_BACK)
      reference_date = datetime(year=2030, month=12, day=1).date()
      self.assertTrue(parser.is_expired(reference_date))
Esempio n. 15
0
 def test_is_front(self):
      parser = DNIScumParser(DNI_NEW_NO_BACK)
      self.assertTrue(parser.is_front())
Esempio n. 16
0
 def test_not_is_front(self):
      parser = DNIScumParser(DNI_ONLY_BACK)
      self.assertFalse(parser.is_front())
Esempio n. 17
0
 def test_is_back(self):
      parser = DNIScumParser(DNI_NEW)
      self.assertTrue(parser.is_back())
Esempio n. 18
0
 def test_check_id_complete_dni(self):
      parser = DNIScumParser(DNI_OLD)
      self.assertTrue(parser.check_id('56933095f'))
Esempio n. 19
0
 def test_not_is_expired_with_back_mr(self):
      parser = DNIScumParser(DNI_NEW)
      reference_date = datetime(year=2017, month=12, day=1).date()
      self.assertFalse(parser.is_expired(reference_date))
Esempio n. 20
0
 def test_check_person_not_found(self):
      parser = DNIScumParser(DNI_NEW)
      self.assertFalse(parser.check_person({'name': 'jose', 'surnames': 'martinez dorado'}))
Esempio n. 21
0
 def test_check_person_found(self):
      parser = DNIScumParser(DNI_NEW)
      self.assertTrue(parser.check_person({'name': 'ramon', 'surnames': 'alvarez dorado'}))
Esempio n. 22
0
 def test_check_id_only_back_not_found(self):
      parser = DNIScumParser(DNI_OLD_ONLY_BACK)
      self.assertFalse(parser.check_id('89933095f'))
Esempio n. 23
0
 def test_check_id_only_back(self):
      parser = DNIScumParser(DNI_OLD_ONLY_BACK)
      self.assertTrue(parser.check_id('56933095f'))
Esempio n. 24
0
 def test_check_id_only_front(self):
      parser = DNIScumParser(DNI_OLD_NO_BACK)
      self.assertTrue(parser.check_id('56933095f'))
Esempio n. 25
0
 def test_analysis_dates_not_found(self):
     parser = DNIScumParser(DNI_NO_DATES)
     self.assertAnalysis([parser.BACK], parser.analysis(person={'name': 'begoña',
                                                 'surnames': 'sanz perez', 'id': '25748789r'}))
Esempio n. 26
0
 def test_analysis_new_dni_valid_with_only_number(self):
      parser = DNIScumParser(DNI_NEW)
      reference_date = datetime(year=2017, month=11, day=1).date()
      self.assertAnalysis([parser.VALID], parser.analysis(person={'name': 'ramon', 'surnames': 'alvarez dorado'},
                                                          reference_date=reference_date))
Esempio n. 27
0
 def test_analysis_keywords_not_found(self):
     parser = DNIScumParser(DNI_NO_KEYWORDS)
     self.assertAnalysis([parser.BACK], parser.analysis(person={'name': 'manuel',
                                                         'surnames': 'martinez perez', 'id': '16925657p'}))
Esempio n. 28
0
 def test_analysis_new_dni_not_client(self):
      parser = DNIScumParser(DNI_NEW)
      reference_date = datetime(year=2017, month=11, day=1).date()
      self.assertAnalysis([parser.FRONT, parser.BACK, parser.NOT_VALID_PERSON],
                          parser.analysis(person={'name': 'luis', 'surnames': 'alvarez dorado', 'id': '14900073d'},
                                          reference_date=reference_date))
Esempio n. 29
0
 def test_check_id_complete_dni_not_found(self):
      parser = DNIScumParser(DNI_OLD)
      self.assertFalse(parser.check_id('77 933095f'))
Esempio n. 30
0
 def test_not_is_back(self):
      parser = DNIScumParser(DNI_NEW_NO_BACK)
      self.assertFalse(parser.is_back())