Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g4.85 Update Validators: EmptyCell, ValueInList and DuplicateTraits #106

Merged
merged 35 commits into from
Oct 2, 2024

Conversation

carolyncaron
Copy link
Contributor

@carolyncaron carolyncaron commented Sep 4, 2024

Issue #85

Dependencies

#105 - complete!

Motivation

The 3 validators I have been primarily working on - EmptyCell, ValueInList, and Duplicate Traits - needed to be updated to accept configuration using setters and to return the new return values. This involved updating the tests and configuring the validators in the importer formValidate().

What does this PR do?

  1. Updates each validator to use their respective traits to set and get configuration values

    EmptyCell:

    • Use getIndices() in validateRow()
    • Use setIndices() in configureValidators()

    ValueInList:

    • Use getIndices() in validateRow()
    • Use setIndices() in configureValidators()
    • Use getValidValues() in validateRow()
    • Use setValidValues() in configureValidators()

    DuplicateTraits:

    • Use getConfiguredGenus() in validateRow()
    • Use setConfiguredGenus() in configureValidators()
    • Use getIndices() in validateRow()
    • Use setIndices() in configureValidators()
  2. Updates the validators to indicate their inputType and removes their scope in the annotation block.

    • EmptyCell
    • ValueInList
    • DuplicateTraits
    • Update ValidatorFileRowScopeTest and ValidatorTraitImporterTest to remove mention of scope
  3. Updates the validators to return the new style of return information:

    'case': a developer focused string describing the case checked
    'valid': either TRUE or FALSE depending on if the data is valid or not
    'failedItems': an array of "items" to be used in the message to the user. This is empty if the data was valid

    • EmptyCell
    • ValueInList
    • DuplicateTraits
  4. Updates were made to the formValidate() method in the Traits Importer class:

    • Removed all reference to the old return style specifically for data-row validators
    • Removed the declaration of the $validation array and its use- validation results are no longer stored as they happen
    • Instead, validation results are now being stored in the $failures array only if validation fails. The $failures[$validation_name] array only gets declared if validation occurs at all for that validator instance, which will be used later to determine which validation statuses need to be 'pass' vs 'todo'.
    • Added a new method processValidationMessages() to handle the $failures array and to define the default messages which will later be passed to the user through the UI

Testing

Automated Testing

Some tests were re-organized as follows:

  • ValidatorFileRowScopeTest.php was removed
    • ValidatorFileRowScopeTest::testValidatorValueInList() => ValidatorValueInListTest::testValidatorValueInList()
    • ValidatorFileRowScopeTest::testValidatorEmptyCell() => ValidatorEmptyCellTest::testValidatorEmptyCell()
  • ValidatorTraitImporterTest was renamed and all of its methods moved to ValidatorDuplicateTraitsTest

NEW Test added

  • testIndexKeyExceptions() was added to ValidatorDuplicateTraitsTest
    • checks for each of the index keys that were configured with setIndices() using data provider provideWrongIndexKeys()
      • Trait Name
      • Method Short Name
      • Unit

The following tests were updated by adding additional asserts to check for all of the expected values in the return array

  • ValidatorValueInListTest::testValidatorValueInList()
  • ValidatorEmptyCellTest::testValidatorEmptyCell()
  • ValidatorDuplicateTraitsTest::testValidatorDuplicateTraitsFile()
  • ValidatorDuplicateTraitsTest::testValidatorDuplicateTraitsDatabase()

Miscellaneous updates

  • TraitImporterFormValidateTest::testTraitFormValidation() has a new assert for ensure the 'details' value in the data provider is not an empty string
    • also added documentation to both the data provider and test method
  • ValidatorBaseTest was modified to use the base fake validator instead of being dependent on an instance of the ValueInList validator

…me of ValidatorTraitImporterTest. This means each of the data-row validators have their own test file
@carolyncaron carolyncaron marked this pull request as ready for review September 23, 2024 22:50
Copy link
Member

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great! Just a few more concrete comments:

  • Do we need to set the genus in the validator or is it done by the trait?
  • ensure raw_results at the same level as the title/details
  • make clear in comments that the key from processValidationMessages() is the unique identifier of the validator UI line that just happens to currently be the validator instance key but may not continue to be so.

Co-authored-by: Lacey-Anne Sanderson <las166@mail.usask.ca>
Copy link
Member

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes look great.

Only thing I noticed was that there is a gap in the test coverage that must have snuck in the previous PR 🙈
Screenshot 2024-09-26 at 2 52 07 PM

Copy link

codeclimate bot commented Oct 1, 2024

Code Climate has analyzed commit e688f14 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 94.5% (50% is the threshold).

This pull request will bring the total coverage in the repository to 70.8% (0.0% change).

View more on Code Climate.

@carolyncaron
Copy link
Contributor Author

Thanks @laceysanderson! I created a new test testIndexKeyExceptions and data provider provideWrongIndexKeys to cover all 3 of those exception messages in commit b65a321

Copy link
Member

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! Only remaining gaps in test coverage are related to new vs. old return style which will soon be resolved!

Ready to merge! 🎉

@laceysanderson laceysanderson merged commit 66326bd into 4.x Oct 2, 2024
19 checks passed
@laceysanderson laceysanderson deleted the g4.85-updateTraitDataValidators branch October 2, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants