-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_faker_credit_score.py
71 lines (58 loc) · 2.25 KB
/
test_faker_credit_score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import unittest
import re
from faker import Faker
from faker_credit_score import CreditScore
class TestEnUS(unittest.TestCase):
def setUp(self):
self.factory = Faker("en_US")
self.factory.add_provider(CreditScore)
self.factory.seed(0)
def test_random_credit_score(self):
for _ in range(100):
credit_score = self.factory.credit_score()
assert 300 <= credit_score <= 850
def test_credit_score_of_a_specific_type(self):
for _ in range(100):
credit_score = self.factory.credit_score("fico8")
assert 300 <= credit_score <= 850
def test_random_credit_score_provider(self):
for _ in range(100):
provider = self.factory.credit_score_provider()
assert provider in ("FICO", "Experian", "Equifax", "TransUnion")
def test_credit_score_provider_of_a_specific_type(self):
for _ in range(100):
provider = self.factory.credit_score_provider("fico5")
assert provider == "Equifax"
def test_random_credit_score_name(self):
for _ in range(100):
name = self.factory.credit_score_name()
assert name in (
"FICO Score 8",
"Equifax Beacon 5.0",
"Experian/Fair Isaac Risk Model V2SM",
"TransUnion FICO Risk Score, Classic 04",
)
def test_credit_score_name_of_a_specific_type(self):
for _ in range(100):
name = self.factory.credit_score_name("fico5")
assert name == "Equifax Beacon 5.0"
def test_random_credit_score_full(self):
""" Output looks like this (provider/model is random):
Equifax Beacon 5.0
Equifax
660
"""
for _ in range(100):
output = self.factory.credit_score_full()
assert re.match(r".+\n.+\n\d{3}\n", output)
def test_credit_score_full_of_a_specific_type(self):
""" Output looks like this:
Equifax Beacon 5.0
Equifax
660
"""
for _ in range(100):
output = self.factory.credit_score_full("fico5")
assert re.match(r"Equifax Beacon 5\.0\nEquifax\n\d{3}\n", output)