Example #1
0
    def test_deveria_lancar_excecao_se_ha_caracteres_nao_esperado_no_numero(self):
        with self.assertRaises(ValidationError):
            utils.CPF([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "a"])

        with self.assertRaises(ValidationError):
            utils.CPF([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "*"])

        with self.assertRaises(ValidationError):
            utils.CPF([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "^"])
Example #2
0
 def test_deveria_lancar_excecao_se_nao_houver_todos_os_numeros(self):
     with self.assertRaises(ValidationError):
         utils.CPF(["1" * 10])
Example #3
0
 def test_deveria_definir_numeros_no_atributo_cpf(self):
     cpf = utils.CPF("1" * 11)
     self.assertEqual("1" * 11, cpf.cpf)
Example #4
0
 def test_deveria_ser_diferente_para_numero_invalido(self):
     self.assertTrue("2" * 10 != utils.CPF("1" * 11))
Example #5
0
 def test_getitem_deveria_numero_da_posicao_correspondente(self):
     self.assertEqual("7", utils.CPF("67594476387")[1])
Example #6
0
 def test_repr_deveria_numero_com_nome_da_classe(self):
     self.assertEqual("CPF('67594476387')", repr(utils.CPF("67594476387")))
Example #7
0
 def test_str_deveria_retornar_o_numero_formatado(self):
     self.assertEqual("675.944.763-87", str(utils.CPF("67594476387")))
Example #8
0
 def test_avaliacao_booleana_deveria_ser_valido(self):
     self.assertTrue(bool(utils.CPF("675.944.763-87")))
Example #9
0
 def test_deveria_ser_diferente(self):
     self.assertFalse("2" * 11 == utils.CPF("1" * 11))
Example #10
0
 def test_deveria_ser_igual(self):
     self.assertTrue("1" * 11 == utils.CPF("1" * 11))
Example #11
0
 def test_numero_deveria_ser_invalido(self):
     self.assertFalse(utils.CPF("675.944.763-80").valido())
Example #12
0
 def test_numero_deveria_ser_valido(self):
     self.assertTrue(utils.CPF("675.944.763-87").valido())
Example #13
0
 def test_format_deveria_adicionar_pontos_e_traco_no_numero(self):
     self.assertEqual("111.111.111-11", utils.CPF("11111111111").format())
Example #14
0
 def test_deveria_remover_caracteres_ponto_e_traco_do_numero(self):
     cpf = utils.CPF("111.111.111-11")
     self.assertEqual("11111111111", cpf.cpf)
Example #15
0
 def test_deveria_transformar_lista_de_numeros_em_string_unica(self):
     cpf = utils.CPF([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
     self.assertEqual("1" * 11, cpf.cpf)
Example #16
0
 def test_deveria_lancar_excecao_se_houver_numeros_a_mais(self):
     with self.assertRaises(ValidationError):
         utils.CPF("1" * 12)