Package: random-uk-bank-account
Random UK Bank AccountA package to generate random test UK bank account numbers for a given UK sort code
which passVocalink modulus checks.Installpip3 install random-uk-bank-accountUsageGenerate Account Numbersfromrandom_uk_bank_accountimportGenerateUkBankAccountaccount=GenerateUkBankAccount().generate_for_sort_code('040004')>>RandomBankAccount(sort_code='040004',account_numbers=['82965944'])account.sort_code>>'040004'account.account_numbers>>['41066722']GenerateUkBankAccount().generate_for_sort_code('040004',total=20)>>RandomBankAccount(sort_code='040004',account_numbers=['92612857','76448619','09409980','95576964','76299182','68185209','44888939','55332169','50496590','42464621','38534657','44047783','91289609','32162555','71814032','33956578','22465479','82075062','16446077','22058275'])GenerateUkBankAccount().generate_for_sort_code('201053',total=5).to_json()>>{"sort_code":"201053","account_numbers":["56990833","67758799","72576465","02666758","28778256"]}Validate Account Numbersfromrandom_uk_bank_accountimportGenerateUkBankAccountGenerateUkBankAccount().validate(sort_code='040004',account_number='82965944')>>TrueGet Vocalink Rulesfromrandom_uk_bank_accountimportGenerateUkBankAccountGenerateUkBankAccount().get_vocalink_rules(sort_code='040004')>>VocalinkRuleCollection(rules=[VocalinkRule(sort_code_from='040004',sort_code_to='040004',algorithm=VocalinkAlgorithmType(name='DBLAL',modulus=10),sort_code_pos_1=0,sort_code_pos_2=0,sort_code_pos_3=0,sort_code_pos_4=0,sort_code_pos_5=0,sort_code_pos_6=0,account_number_pos_1=8,account_number_pos_2=7,account_number_pos_3=6,account_number_pos_4=5,account_number_pos_5=4,account_number_pos_6=3,account_number_pos_7=2,account_number_pos_8=1,exception='0')])GenerateUkBankAccount().get_vocalink_rules(sort_code='040004').to_json()>>{"rules":[{"sort_code_from":"040004","sort_code_to":"040004","algorithm":["DBLAL",10],"sort_code_pos_1":0,"sort_code_pos_2":0,"sort_code_pos_3":0,"sort_code_pos_4":0,"sort_code_pos_5":0,"sort_code_pos_6":0,"account_number_pos_1":8,"account_number_pos_2":7,"account_number_pos_3":6,"account_number_pos_4":5,"account_number_pos_5":4,"account_number_pos_6":3,"account_number_pos_7":2,"account_number_pos_8":1,"exception":"0"}]}Get Vocalink Sort Code Substitutionsfromrandom_uk_bank_accountimportGenerateUkBankAccountGenerateUkBankAccount().get_all_vocalink_substitutions()GenerateUkBankAccount().get_all_vocalink_substitutions().to_json()GenerateUkBankAccount().get_vocalink_substitution(sort_code='938628')>>VocalinkSortCodeSubstitution(original_sort_code='938628',substituted_sort_code='938181')GenerateUkBankAccount().get_vocalink_substitution(sort_code='938628').to_json()>>{"original_sort_code":"938628","substituted_sort_code":"938181"}Additional OptionsLoggingBy default logging is set to ERROR. To enable debug uselog_level:GenerateUkBankAccount(log_level=logging.DEBUG).generate_for_sort_code(sort_code='040004',total=5)STDOUT >>
    2021-04-28 17:53:37,970 - random-bank-account - DEBUG - 4889/valacdos has been cached previously in /Users/{USER}/.vocalink
    2021-04-28 17:53:37,970 - random-bank-account - DEBUG - 1517/scsubtab has been cached previously in /Users/{USER}/.vocalink
    2021-04-28 17:53:37,971 - random-bank-account - DEBUG - Vocalink rules: {"rules": [{"sort_code_from": "040004", "sort_code_to": "040004", "algorithm": ["DBLAL", 10], "sort_code_pos_1": 0, "sort_code_pos_2": 0, "sort_code_pos_3": 0, "sort_code_pos_4": 0, "sort_code_pos_5": 0, "sort_code_pos_6": 0, "account_number_pos_1": 8, "account_number_pos_2": 7, "account_number_pos_3": 6, "account_number_pos_4": 5, "account_number_pos_5": 4, "account_number_pos_6": 3, "account_number_pos_7": 2, "account_number_pos_8": 1, "exception": "0"}]}
    2021-04-28 17:53:37,971 - random-bank-account - DEBUG - Vocalink sort code substitutions: {"original_sort_code": null, "substituted_sort_code": null}
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - Generating Bank Account for 040004. Seed array: [1, 6, 2, 6, 7, 7, 2, 1] 
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - Account Number [5, 6, 3, 6, 7, 7, 2, 1] satisfies checks after 5 numeric changes
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - 1/2 account numbers generated
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - Generating Bank Account for 040004. Seed array: [9, 0, 4, 3, 5, 0, 4, 5] 
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - Account Number [9, 1, 4, 6, 5, 0, 4, 5] satisfies checks after 4 numeric changes
    2021-04-28 17:53:37,972 - random-bank-account - DEBUG - 2/2 account numbers generatedVocalink CachingBy default Vocalink data is retrieved from the Vocalink website and permanently cached in a sqlite database located in
the home directory under the folder.vocalink.The cache can be recreated withrecreate_vocalink_db:GenerateUkBankAccount(log_level=logging.DEBUG,recreate_vocalink_db=True)STDOUT >>
    2021-04-28 17:58:56,373 - random-bank-account - DEBUG - Deleting previously created /Users/{USER}/.vocalink/4889-valacdos.db
    2021-04-28 17:58:56,571 - random-bank-account - DEBUG - Vocalink data saved to /Users/{USER}/.vocalink/4889-valacdos.dbThe location for the cache can be overwritten withcache_location:GenerateUkBankAccount(cache_location='some/real/path')Vocalink VersionThe version of Vocalink is defaulted to values inconfig. These are retrievable via:GenerateUkBankAccount().VOCALINK_VERSIONGenerateUkBankAccount().VOCALINK_SUBSTITUTION_VERSIONThe version can be overwitten viavocalink_rules_versionandvocalink_substitution_version. The values of which
are taken from the Vocalink URLs shown in bold below.https://www.vocalink.com/media/4941/valacdos.txt
https://www.vocalink.com/media/1517/scsubtab.txtFor example:GenerateUkBankAccount(recreate_vocalink_db=True,vocalink_rules_version='4941/valacdos',vocalink_substitution_version='1517/scsubtab')Vocalink source data is regularly removed from the Vocalink versions. If the versions
specified in config no longer exist an attempt is made to get the latest versions through parsing
Vocalink website HTML.TestsClone the repository and run:make test