From 0c5cee9df22579d7c6327133b4107f2f6c22d421 Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Wed, 22 Aug 2018 08:48:21 -0400 Subject: [PATCH 1/5] Scaffold Codacy --- .codacy.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .codacy.yml diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 0000000..cfd240a --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,21 @@ +--- +engines: + pylint: + enabled: true + python_version: 3 + + duplication: + enabled: true + + metrics: + enabled: true + + coverage: + enabled: true + +languages: + python: + +exclude_paths: +- tests/* +- setup.py From bebf61398f6c54ab6c42cbbf5bab467a2164ebf6 Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Wed, 22 Aug 2018 09:31:01 -0400 Subject: [PATCH 2/5] Make lists immutable --- faker_credit_score/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/faker_credit_score/__init__.py b/faker_credit_score/__init__.py index d1cb6e3..a3b3916 100644 --- a/faker_credit_score/__init__.py +++ b/faker_credit_score/__init__.py @@ -6,7 +6,7 @@ class CreditScoreObject(object): - def __init__(self, name="FICO SCORE 8", provider="FICO", score_range=[300, 850]): + def __init__(self, name="FICO SCORE 8", provider="FICO", score_range=(300, 850)): self.name = name self.provider = provider self.score_range = score_range @@ -22,10 +22,10 @@ class CreditScore(BaseProvider): # * https://blog.myfico.com/whats-a-good-credit-score-range/ # * https://www.wrightrealtors.com/home/credit-score.htm - fico8_range = [300, 850] - fico5_range = [334, 818] - fico2_range = [320, 844] - fico4_range = [309, 839] + fico8_range = (300, 850) + fico5_range = (334, 818) + fico2_range = (320, 844) + fico4_range = (309, 839) credit_score_types = OrderedDict( ( From 69b9053dd0d2d1381269f7c55c2a2c2e44872068 Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Wed, 22 Aug 2018 10:12:01 -0400 Subject: [PATCH 3/5] Expand hardcoded provider for fico8 --- faker_credit_score/__init__.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/faker_credit_score/__init__.py b/faker_credit_score/__init__.py index a3b3916..db08226 100644 --- a/faker_credit_score/__init__.py +++ b/faker_credit_score/__init__.py @@ -1,14 +1,19 @@ # coding=utf-8 from __future__ import unicode_literals -from collections import namedtuple, OrderedDict +from collections import OrderedDict from faker.providers import BaseProvider class CreditScoreObject(object): - def __init__(self, name="FICO SCORE 8", provider="FICO", score_range=(300, 850)): + def __init__( + self, + name="FICO Score 8", + providers=("Equifax", "Experian", "TransUnion"), + score_range=(300, 850), + ): self.name = name - self.provider = provider + self.providers = providers self.score_range = score_range @@ -22,17 +27,28 @@ class CreditScore(BaseProvider): # * https://blog.myfico.com/whats-a-good-credit-score-range/ # * https://www.wrightrealtors.com/home/credit-score.htm + fico8_name = "FICO Score 8" + fico8_providers = ("Equifax", "Experian", "TransUnion") fico8_range = (300, 850) + + fico5_name = "Equifax Beacon 5.0" + fico5_providers = ("Equifax",) fico5_range = (334, 818) + + fico2_name = "Experian/Fair Isaac Risk Model V2SM" + fico2_providers = ("Experian",) fico2_range = (320, 844) + + fico4_name = "TransUnion FICO Risk Score, Classic 04" + fico4_providers = ("TransUnion",) fico4_range = (309, 839) credit_score_types = OrderedDict( ( - ("fico8", CreditScoreObject("FICO Score 8", "FICO", fico8_range)), - ("fico5", CreditScoreObject("Equifax Beacon 5.0", "Equifax", fico5_range)), - ("fico2", CreditScoreObject("Experian/Fair Isaac Risk Model V2SM", "Experian", fico2_range)), - ("fico4", CreditScoreObject("TransUnion FICO Risk Score, Classic 04", "TransUnion", fico4_range)), + ("fico8", CreditScoreObject(fico8_name, fico8_providers, fico8_range)), + ("fico5", CreditScoreObject(fico5_name, fico5_providers, fico5_range)), + ("fico2", CreditScoreObject(fico2_name, fico2_providers, fico2_range)), + ("fico4", CreditScoreObject(fico4_name, fico4_providers, fico4_range)), ) ) credit_score_types["fico"] = credit_score_types["fico8"] @@ -47,7 +63,7 @@ def credit_score_provider(self, score_type=None): """ Returns the name of the credit score provider. """ if score_type is None: score_type = self.random_element(self.credit_score_types.keys()) - return self._credit_score_type(score_type).provider + return self.random_element(self._credit_score_type(score_type).providers) def credit_score(self, score_type=None): """ Returns a valid credit score. """ From e31adf78859985af372b47b4dd48d0edeccbc06a Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Thu, 23 Aug 2018 20:22:20 -0400 Subject: [PATCH 4/5] Scaffold coveralls support --- .coveragerc | 2 +- .travis.yml | 3 +- Makefile | 7 +++- Pipfile | 1 + Pipfile.lock | 111 ++++++++++++++++++++++++++++++++++++--------------- 5 files changed, 87 insertions(+), 37 deletions(-) diff --git a/.coveragerc b/.coveragerc index fa87464..fbdf0a3 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,3 @@ [run] source = . -omit = setup.py,tests/*,faker_credit_score/__version__.py +omit = setup.py,tests/*,faker_credit_score/__version__.py,.venv/* diff --git a/.travis.yml b/.travis.yml index 5494a2f..39877f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,5 @@ env: # command to install dependencies install: make setup # # command to run tests -script: make test \ No newline at end of file +script: make test +after_success: make coverage diff --git a/Makefile b/Makefile index 1b2baef..65d6e9e 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,12 @@ setup: pipenv install --dev --three activate: - pipenv shell -c + pipenv shell test: - pipenv run python -m unittest tests/test_faker_credit_score.py + pipenv run coverage run -m unittest tests/* + +coverage: + pipenv run coveralls .PHONY: help activate test diff --git a/Pipfile b/Pipfile index ef66afb..58ae8c8 100644 --- a/Pipfile +++ b/Pipfile @@ -8,6 +8,7 @@ name = "pypi" [dev-packages] coverage = "*" faker = "*" +python-coveralls = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index 999cea8..661f1ae 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "4eaf82210eab11f0e92fbadba1ced5b415f8ce41d9e668b99cd2519a70d2d44b" + "sha256": "9ce8a21d7659643b6b835bdaea39ee8546d61cdb59aa7f96e60bf20f736b4ae9" }, "pipfile-spec": 6, "requires": { @@ -17,42 +17,42 @@ }, "default": {}, "develop": { + "certifi": { + "hashes": [ + "sha256:4c1d68a1408dd090d2f3a869aa94c3947cc1d967821d1ed303208c9f41f0f2f4", + "sha256:b6e8b28b2b7e771a41ecdd12d4d43262ecab52adebbafa42c77d6b57fb6ad3a4" + ], + "version": "==2018.8.13" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, "coverage": { "hashes": [ - "sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba", - "sha256:0b136648de27201056c1869a6c0d4e23f464750fd9a9ba9750b8336a244429ed", - "sha256:10a46017fef60e16694a30627319f38a2b9b52e90182dddb6e37dcdab0f4bf95", - "sha256:198626739a79b09fa0a2f06e083ffd12eb55449b5f8bfdbeed1df4910b2ca640", - "sha256:23d341cdd4a0371820eb2b0bd6b88f5003a7438bbedb33688cd33b8eae59affd", - "sha256:28b2191e7283f4f3568962e373b47ef7f0392993bb6660d079c62bd50fe9d162", - "sha256:2a5b73210bad5279ddb558d9a2bfedc7f4bf6ad7f3c988641d83c40293deaec1", - "sha256:2eb564bbf7816a9d68dd3369a510be3327f1c618d2357fa6b1216994c2e3d508", - "sha256:337ded681dd2ef9ca04ef5d93cfc87e52e09db2594c296b4a0a3662cb1b41249", - "sha256:3a2184c6d797a125dca8367878d3b9a178b6fdd05fdc2d35d758c3006a1cd694", - "sha256:3c79a6f7b95751cdebcd9037e4d06f8d5a9b60e4ed0cd231342aa8ad7124882a", - "sha256:3d72c20bd105022d29b14a7d628462ebdc61de2f303322c0212a054352f3b287", - "sha256:3eb42bf89a6be7deb64116dd1cc4b08171734d721e7a7e57ad64cc4ef29ed2f1", - "sha256:4635a184d0bbe537aa185a34193898eee409332a8ccb27eea36f262566585000", - "sha256:56e448f051a201c5ebbaa86a5efd0ca90d327204d8b059ab25ad0f35fbfd79f1", - "sha256:5a13ea7911ff5e1796b6d5e4fbbf6952381a611209b736d48e675c2756f3f74e", - "sha256:69bf008a06b76619d3c3f3b1983f5145c75a305a0fea513aca094cae5c40a8f5", - "sha256:6bc583dc18d5979dc0f6cec26a8603129de0304d5ae1f17e57a12834e7235062", - "sha256:701cd6093d63e6b8ad7009d8a92425428bc4d6e7ab8d75efbb665c806c1d79ba", - "sha256:7608a3dd5d73cb06c531b8925e0ef8d3de31fed2544a7de6c63960a1e73ea4bc", - "sha256:76ecd006d1d8f739430ec50cc872889af1f9c1b6b8f48e29941814b09b0fd3cc", - "sha256:7aa36d2b844a3e4a4b356708d79fd2c260281a7390d678a10b91ca595ddc9e99", - "sha256:7d3f553904b0c5c016d1dad058a7554c7ac4c91a789fca496e7d8347ad040653", - "sha256:7e1fe19bd6dce69d9fd159d8e4a80a8f52101380d5d3a4d374b6d3eae0e5de9c", - "sha256:8c3cb8c35ec4d9506979b4cf90ee9918bc2e49f84189d9bf5c36c0c1119c6558", - "sha256:9d6dd10d49e01571bf6e147d3b505141ffc093a06756c60b053a859cb2128b1f", - "sha256:be6cfcd8053d13f5f5eeb284aa8a814220c3da1b0078fa859011c7fffd86dab9", - "sha256:c1bb572fab8208c400adaf06a8133ac0712179a334c09224fb11393e920abcdd", - "sha256:de4418dadaa1c01d497e539210cb6baa015965526ff5afc078c57ca69160108d", - "sha256:e05cb4d9aad6233d67e0541caa7e511fa4047ed7750ec2510d466e806e0255d6", - "sha256:f3f501f345f24383c0000395b26b726e46758b71393267aeae0bd36f8b3ade80" + "sha256:00d464797a236f654337181af72b4baea3d35d056ca480e45e9163bb5df496b8", + "sha256:0a90afa6f5ea08889da9066dca3ce2ef85d47587e3f66ca06a4fa8d3a0053acc", + "sha256:50727512afe77e044c7d7f2fd4cd0fe62b06527f965b335a810d956748e0514d", + "sha256:6c2fd127cd4e2decb0ab41fe3ac2948b87ad2ea0470e24b4be5f7e7fdfef8df3", + "sha256:6ed521ed3800d8f8911642b9b3c3891780a929db5e572c88c4713c1032530f82", + "sha256:76a73a48a308fb87a4417d630b0345d36166f489ef17ea5aa8e4596fb50a2296", + "sha256:85b1275b6d7a61ccc8024a4e9a4c9e896394776edce1a5d075ec116f91925462", + "sha256:8e60e720cad3ee6b0a32f475ae4040552c5623870a9ca0d3d4263faa89a8d96b", + "sha256:93c50475f189cd226e9688b9897a0cd3c4c5d9c90b1733fa8f6445cfc0182c51", + "sha256:94c1e66610807a7917d967ed6415b9d5fde7487ab2a07bb5e054567865ef6ef0", + "sha256:964f86394cb4d0fd2bb40ffcddca321acf4323b48d1aa5a93db8b743c8a00f79", + "sha256:99043494b28d6460035dd9410269cdb437ee460edc7f96f07ab45c57ba95e651", + "sha256:af2f59ce312523c384a7826821cae0b95f320fee1751387abba4f00eed737166", + "sha256:beb96d32ce8cfa47ec6433d95a33e4afaa97c19ac1b4a47ea40a424fedfee7c2", + "sha256:c00bac0f6b35b82ace069a6a0d88e8fd4cd18d964fc5e47329cd02b212397fbe", + "sha256:d079e36baceea9707fd50b268305654151011274494a33c608c075808920eda8", + "sha256:e813cba9ff0e3d37ad31dc127fac85d23f9a26d0461ef8042ac4539b2045e781" ], "index": "pypi", - "version": "==4.5.1" + "version": "==4.0.3" }, "faker": { "hashes": [ @@ -62,6 +62,21 @@ "index": "pypi", "version": "==0.9.0" }, + "idna": { + "hashes": [ + "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e", + "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16" + ], + "version": "==2.7" + }, + "python-coveralls": { + "hashes": [ + "sha256:1748272081e0fc21e2c20c12e5bd18cb13272db1b130758df0d473da0cb31087", + "sha256:736dda01f64beda240e1500d5f264b969495b05fcb325c7c0eb7ebbfd1210b70" + ], + "index": "pypi", + "version": "==2.9.1" + }, "python-dateutil": { "hashes": [ "sha256:1adb80e7a782c12e52ef9a8182bebeb73f1d7e24e374397af06fb4956c8dc5c0", @@ -69,6 +84,29 @@ ], "version": "==2.7.3" }, + "pyyaml": { + "hashes": [ + "sha256:3d7da3009c0f3e783b2c873687652d83b1bbfd5c88e9813fb7e5b03c0dd3108b", + "sha256:3ef3092145e9b70e3ddd2c7ad59bdd0252a94dfe3949721633e41344de00a6bf", + "sha256:40c71b8e076d0550b2e6380bada1f1cd1017b882f7e16f09a65be98e017f211a", + "sha256:558dd60b890ba8fd982e05941927a3911dc409a63dcb8b634feaa0cda69330d3", + "sha256:a7c28b45d9f99102fa092bb213aa12e0aaf9a6a1f5e395d36166639c1f96c3a1", + "sha256:aa7dd4a6a427aed7df6fb7f08a580d68d9b118d90310374716ae90b710280af1", + "sha256:bc558586e6045763782014934bfaf39d48b8ae85a2713117d16c39864085c613", + "sha256:d46d7982b62e0729ad0175a9bc7e10a566fc07b224d2c79fafb5e032727eaa04", + "sha256:d5eef459e30b09f5a098b9cea68bebfeb268697f78d647bd255a085371ac7f3f", + "sha256:e01d3203230e1786cd91ccfdc8f8454c8069c91bee3962ad93b87a4b2860f537", + "sha256:e170a9e6fcfd19021dd29845af83bb79236068bf5fd4df3327c1be18182b2531" + ], + "version": "==3.13" + }, + "requests": { + "hashes": [ + "sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1", + "sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a" + ], + "version": "==2.19.1" + }, "six": { "hashes": [ "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", @@ -82,6 +120,13 @@ "sha256:801e38bd550b943563660a91de8d4b6fa5df60a542be9093f7abf819f86050cc" ], "version": "==1.2" + }, + "urllib3": { + "hashes": [ + "sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf", + "sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5" + ], + "version": "==1.23" } } } From 03557e911c80764cdb73cfbb3fbcfd998b37369e Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Thu, 6 Sep 2018 13:42:26 -0400 Subject: [PATCH 5/5] Prepare for release 0.2.0 --- Pipfile.lock | 6 +++--- faker_credit_score/__init__.py | 5 ++++- faker_credit_score/__version__.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index 661f1ae..faa742e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -19,10 +19,10 @@ "develop": { "certifi": { "hashes": [ - "sha256:4c1d68a1408dd090d2f3a869aa94c3947cc1d967821d1ed303208c9f41f0f2f4", - "sha256:b6e8b28b2b7e771a41ecdd12d4d43262ecab52adebbafa42c77d6b57fb6ad3a4" + "sha256:376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638", + "sha256:456048c7e371c089d0a77a5212fb37a2c2dce1e24146e3b7e0261736aaeaa22a" ], - "version": "==2018.8.13" + "version": "==2018.8.24" }, "chardet": { "hashes": [ diff --git a/faker_credit_score/__init__.py b/faker_credit_score/__init__.py index db08226..3147e1c 100644 --- a/faker_credit_score/__init__.py +++ b/faker_credit_score/__init__.py @@ -6,6 +6,7 @@ class CreditScoreObject(object): + """ Credit Score Object that uses fico8 as a sensible default. """ def __init__( self, name="FICO Score 8", @@ -17,7 +18,7 @@ def __init__( self.score_range = score_range -class CreditScore(BaseProvider): +class Provider(BaseProvider): # FICO 8 Score is the most widely-used non-industry specific credit score model, # followed by 5, 2, and 4 as per https://www.myfico.com/credit-education/credit-scores/fico-score-versions @@ -94,3 +95,5 @@ def _credit_score_type(self, score_type=None): def _generate_credit_score(self, credit_score_range): """ Returns an integer within the range specified by credit_score_range. """ return self.generator.random_int(*credit_score_range) + +CreditScore = Provider diff --git a/faker_credit_score/__version__.py b/faker_credit_score/__version__.py index da26330..706d68a 100644 --- a/faker_credit_score/__version__.py +++ b/faker_credit_score/__version__.py @@ -1,4 +1,4 @@ """Package version.""" -VERSION = (0, 1, 1) +VERSION = (0, 2, 0) __version__ = '.'.join(map(str, VERSION))