def test_build_with_simple_attributes(): builder = DynamicPolicyBuilder() builder.with_family_name() builder.with_given_names() builder.with_full_name() builder.with_date_of_birth() builder.with_gender() builder.with_postal_address() builder.with_structured_postal_address() builder.with_nationality() builder.with_phone_number() builder.with_selfie() builder.with_email() builder.with_document_details() policy = builder.build() attr_names = [attr["name"] for attr in policy["wanted"]] assert len(policy["wanted"]) == 12 assert config.ATTRIBUTE_FAMILY_NAME in attr_names assert config.ATTRIBUTE_GIVEN_NAMES in attr_names assert config.ATTRIBUTE_FULL_NAME in attr_names assert config.ATTRIBUTE_DATE_OF_BIRTH in attr_names assert config.ATTRIBUTE_GENDER in attr_names assert config.ATTRIBUTE_POSTAL_ADDRESS in attr_names assert config.ATTRIBUTE_STRUCTURED_POSTAL_ADDRESS in attr_names assert config.ATTRIBUTE_NATIONALITY in attr_names assert config.ATTRIBUTE_PHONE_NUMBER in attr_names assert config.ATTRIBUTE_SELFIE in attr_names assert config.ATTRIBUTE_EMAIL_ADDRESS in attr_names assert config.ATTRIBUTE_DOCUMENT_DETAILS in attr_names
def test_build_with_age_derived_attributes(): builder = DynamicPolicyBuilder() builder.with_age_over(18) builder.with_age_under(30) builder.with_age_under(40) policy = builder.build() attrs = [attr["derivation"] for attr in policy["wanted"]] assert len(attrs) == 3 assert config.ATTRIBUTE_AGE_OVER + "18" in attrs assert config.ATTRIBUTE_AGE_UNDER + "30" in attrs assert config.ATTRIBUTE_AGE_UNDER + "40" in attrs