Skip to content

Commit

Permalink
fix ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldrian Harjati committed Aug 21, 2023
1 parent 8fa665a commit c2a4359
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
29 changes: 15 additions & 14 deletions src/tests/test_check_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ def test_conditional_field_conflict_correct(self):

def test_conditional_field_conflict_incorrect(self):
# if ct_loan_term_flag != 900 then ct_loan_term must be blank
# in this test, ct_loan_term_flag is not 900 and ct_loan_term is NOT blank, so must return False
# in this test, ct_loan_term_flag is not 900 and ct_loan_term is
# NOT blank, so must return False
series = pd.Series(["36"], name="ct_loan_term", index=[2])
condition_values: set[str] = {"900"}

Expand Down Expand Up @@ -652,27 +653,27 @@ def test_with_valid_series(self):

def test_with_multiple_valid_series(self):
result = is_unique_column({"ABC123": self.series, "DEF456": self.other_series})
assert result.values[0] == True and result.values[1] == True
assert bool(result.values[0]) is True and bool(result.values[1]) is True

def test_with_invalid_series(self):
result = is_unique_column({"ABC123": self.invalid_series})
assert result.values.all() == False
assert bool(result.values.all()) is False

def test_with_multiple_items_series(self):
result = is_unique_column({"GHI123": self.multi_invalid_series})
assert result.values.all() == False
assert bool(result.values.all()) is False

def test_with_multiple_invalid_series(self):
result = is_unique_column(
{"ABC123": self.invalid_series, "GHI123": self.multi_invalid_series}
)
# ALL rows should be FALSE
assert (
result.values[0] == False
and result.values[1] == False
and result.values[2] == False
and result.values[3] == False
and result.values[4] == False
bool(result.values[0]) is False
and bool(result.values[1]) is False
and bool(result.values[2]) is False
and bool(result.values[3]) is False
and bool(result.values[4]) is False
)

def test_with_multiple_mix_series(self):
Expand All @@ -681,9 +682,9 @@ def test_with_multiple_mix_series(self):
)
# first two rows should be FALSE and last Row should be TRUE
assert (
result.values[0] == False
and result.values[1] == False
and result.values[2] == True
bool(result.values[0]) is False
and bool(result.values[1]) is False
and bool(result.values[2]) is True
)

def test_with_blank_value_series(self):
Expand Down Expand Up @@ -791,7 +792,7 @@ def test_with_incorrect_is_equal_and_not_equal_conditions(self):
"field2": (1, True, "999"),
"field3": (2, True, "0"),
"field4": (3, False, ""),
"field4": (4, False, ""),
"field5": (4, False, ""),
}

series = pd.Series(["0"], name="num_principal_owners", index=[1])
Expand Down Expand Up @@ -867,7 +868,7 @@ def test_with_incorrect_values(self):
string_contains(
"000TESTFIUIDDONOTUSEXGXVID11XTC1",
"000TESTFIUIDDONOTUSEXGX",
end_idx=20,
end_idx=23,
)
is True
)
1 change: 0 additions & 1 deletion src/validator/global_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import re
import sys

import pandas as pd
Expand Down
27 changes: 14 additions & 13 deletions src/validator/phase_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None):
string_contains,
name="uid.invalid_uid_lei",
description=(
"The first 20 characters of the 'unique identifier' should match "
"the Legal Entity Identifier (LEI) for the financial institution."
"The first 20 characters of the 'unique identifier' "
"should match the Legal Entity Identifier (LEI) for "
"the financial institution."
),
element_wise=True,
containing_value=lei,
Expand Down Expand Up @@ -137,8 +138,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None):
is_valid_enum,
name="ct_credit_product.invalid_enum_value",
description=(
"'Credit product' must equal 1, 2, 3, 4, 5, 6, 7, 8, "
"977, or 988."
"'Credit product' must equal 1, 2, 3, 4, 5, 6, "
"7, 8, 977, or 988."
),
element_wise=True,
accepted_values=[
Expand Down Expand Up @@ -950,11 +951,11 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None):
description=(
"When 'interest rate type' does not equal 1"
" (adjustable interest rate, no initial rate period),"
" 3 (initial rate period > 12 months, adjustable interest rate),"
" or 5 (initial rate period <= 12 months, variable interest"
" rate), 'adjustable rate transaction: margin' must be blank."
" When 'interest rate type' equals 1, 3, or 5, 'variable"
" rate transaction: margin' must not be blank."
" 3 (initial rate period > 12 months, adjustable interest "
"rate), or 5 (initial rate period <= 12 months, variable "
"interest rate), 'adjustable rate transaction: margin' must "
"be blank. When 'interest rate type' equals 1, 3, or 5, "
"'variable rate transaction: margin' must not be blank."
),
groupby="pricing_interest_rate_type",
condition_values={"1", "3", "5"},
Expand All @@ -978,8 +979,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None):
is_valid_enum,
name="pricing_adj_index_name.invalid_enum_value",
description=(
"'Adjustable rate transaction: index name' must equal 1, 2, 3, 4,"
"5, 6, 7, 8, 9, 10, 977, or 999."
"'Adjustable rate transaction: index name' must equal "
"1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 977, or 999."
),
element_wise=True,
accepted_values=[
Expand Down Expand Up @@ -1036,8 +1037,8 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None):
max_value=300,
name="pricing_adj_index_name_ff.invalid_text_length",
description=(
"'Adjustable rate transaction: index name: other' must not exceed"
"300 characters in length."
"'Adjustable rate transaction: index name: other' must "
"not exceed 300 characters in length."
),
),
],
Expand Down

0 comments on commit c2a4359

Please sign in to comment.