def METHOD_NAME(
    self, _, subject, expected_affiliation_id, affiliation_attributes=None
):
    # Arrange
    credential_manager = ProQuestCredentialManager()
    patron = self._patron()
    if subject:
        expected_token = json.dumps(subject, cls=SAMLSubjectJSONEncoder)
        data_source = DataSource.lookup(
            self._db,
            BaseSAMLAuthenticationProvider.TOKEN_DATA_SOURCE_NAME,
            autocreate=True,
        )
        Credential.temporary_token_create(
            self._db,
            data_source,
            BaseSAMLAuthenticationProvider.TOKEN_TYPE,
            patron,
            datetime.timedelta(hours=1),
            expected_token,
        )
    # Act
    if affiliation_attributes:
        token = credential_manager.lookup_patron_affiliation_id(
            self._db, patron, affiliation_attributes
        )
    else:
        token = credential_manager.lookup_patron_affiliation_id(self._db, patron)
    # Assert
    assert expected_affiliation_id == token