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

Refactoring entity tests and adding new entity update tests #1021

Merged
merged 6 commits into from
Oct 10, 2023

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Oct 9, 2023

Closes the following issues:

In particular:

commit 1

  • updated entity-parsing unit tests

commit 2

  • moved extra tests of streaming CSVs of entities from worker/entity test to api/datasets test (multi form and updated entities in particular)
  • removed redundant checks and tests from worker/entity test file
  • added entity update tests to relevant sections of api/entities API test file
    • returning current version and data of updated entity
    • audit log events for an entity

commit 3

  • added tests of entity processing errors flagged by worker

commit 4

commit 5

  • tests of basic update logic (can update label and data)

What has been done to verify that this works as intended?

it's mostly all tests!

Why is this the best possible solution? Were any other approaches considered?

Some of the tests got refactored. I moved tests that started in worker/entity but weren't really about the worker into other files, e.g. csv streaming of entities, which was one of the first tests about entities to exist.

Many tests about entity updates have an API endpoint that is most relevant, and it seems reasonable to move tests/parts of tests to those places.

I added one special section to the end of integration/api/entities for capturing update logic. There are some special sections at the bottom of integration/api/datasets specifically for dataset scenarios.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

More reliable entity update behavior

Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.

No

Before submitting this PR, please make sure you have:

  • run make test-full and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

- moved extra tests of streaming CSVs of entities from worker/entity test to datasets test (multi form and updated entities in particular)

- removed redundant checks and tests from worker/entity test file

- added entity update tests to relevant sections of entity API test file
	* returning current version and data of updated entity
	* audit log events for an entity
Copy link
Contributor

@sadiqkhoja sadiqkhoja left a comment

Choose a reason for hiding this comment

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

Liked this reorganization of tests

@@ -156,11 +157,14 @@ const _createEntity = (dataset, entityData, submissionId, submissionDef, submiss
};

const _updateEntity = (dataset, entityData, submissionId, submissionDef, submissionDefId, event) => async ({ Audits, Entities }) => {
if (!(event.action === 'submission.create')) // only update on submission.create
Copy link
Contributor

Choose a reason for hiding this comment

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

should this condition be in _processSubmissionEvent function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I moved these lines into _createEntity

if ((dataset.approvalRequired && event.details.reviewState !== 'approved') ||
      (!dataset.approvalRequired && event.action === 'submission.update'))

it felt reasonable to move this event action check into _updateEntity

@ktuite ktuite merged commit 72f2309 into master Oct 10, 2023
5 checks passed
@ktuite ktuite deleted the ktuite/entity_tests branch October 10, 2023 17:20
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