mirror of https://github.com/zulip/zulip.git
billing: Take advantage of re match notation in normalize_fixture_data.
No change in behavior; just visual code cleanup.
This commit is contained in:
parent
f52e9d143b
commit
84f7a779c4
|
@ -125,10 +125,10 @@ def normalize_fixture_data(decorated_function: CallableT, keep: List[str]=[]) ->
|
|||
}
|
||||
# We'll replace "invoice_prefix": "A35BC4Q" with something like "invoice_prefix": "NORMA01"
|
||||
pattern_translations.update({
|
||||
'"invoice_prefix": "[A-Za-z0-9]{7}"': '"invoice_prefix": "NORMA%02d"',
|
||||
'"fingerprint": "[A-Za-z0-9]{16}"': '"fingerprint": "NORMALIZED%06d"',
|
||||
'"number": "[A-Za-z0-9]{7}-[A-Za-z0-9]{4}"': '"number": "NORMALI-%04d"',
|
||||
'"address": "[A-Za-z0-9]{9}-test_[A-Za-z0-9]{12}"': '"address": "000000000-test_NORMALIZED%02d"',
|
||||
'"invoice_prefix": "([A-Za-z0-9]{7})"': 'NORMA%02d',
|
||||
'"fingerprint": "([A-Za-z0-9]{16})"': 'NORMALIZED%06d',
|
||||
'"number": "([A-Za-z0-9]{7}-[A-Za-z0-9]{4})"': 'NORMALI-%04d',
|
||||
'"address": "([A-Za-z0-9]{9}-test_[A-Za-z0-9]{12})"': '000000000-test_NORMALIZED%02d',
|
||||
# Does not preserve relative ordering of the timestamps, nor any
|
||||
# coordination with the timestamps in setUp mocks (e.g. Plan.created).
|
||||
': (1[5-9][0-9]{8})(?![0-9-])': '1%09d',
|
||||
|
@ -144,8 +144,8 @@ def normalize_fixture_data(decorated_function: CallableT, keep: List[str]=[]) ->
|
|||
if match not in normalized_values[pattern]:
|
||||
normalized_values[pattern][match] = translation % (len(normalized_values[pattern]) + 1,)
|
||||
file_content = file_content.replace(match, normalized_values[pattern][match])
|
||||
file_content = re.sub(r'"risk_score": \d+', '"risk_score": 00', file_content)
|
||||
file_content = re.sub(r'"times_redeemed": \d+', '"times_redeemed": 00', file_content)
|
||||
file_content = re.sub(r'(?<="risk_score": )(\d+)', '00', file_content)
|
||||
file_content = re.sub(r'(?<="times_redeemed": )(\d+)', '00', file_content)
|
||||
# Dates
|
||||
file_content = re.sub(r'[0-3]\d [A-Z][a-z]{2} 20[1-2]\d', 'NORMALIZED DATE', file_content)
|
||||
# IP addresses
|
||||
|
|
Loading…
Reference in New Issue