Let's say we have a model class use to keep track of Fraud Checks:
class FraudCheck(object):
def __init__(self, score_threshold):
self.score = None
self.transaction = None
self.is_fraud = True
self.score_threshold = score_threshold
Should we be writing unit tests for this __init__
method? There are other methods in the class as well.
So should we be writing tests similar to:
@pytest.fixture()
def fraud_data():
account = FraudCheck(
1000
)
return account
def test_fraud_data(fraud_data):
assert fraud_data.score is None
assert fraud_data.transaction is None
assert fraud_data.is_fraud
assert fraud_data.score_threshold == 10
I know this question was marked as a possible duplicate however the other question was a constructor setting on value. In this particular question, we are only setting one value but there are three other variables as well being set to default values. I would think a unit test would be appropriate in case the variables got mixed up during refactoring but I would like other peoples opinions.