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

NOJIRA: Test through tuple traversal #1295

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

alechenninger
Copy link
Collaborator

Link(s) to Jira

  • n/a

Description of Intent of Change(s)

I wanted to test the migrator a bit more, without relying on implementation detail like BindingMappings. To do this I experimented with some change to InMemoryTuples to allow traversing the tuples so we can test relationships without necessarily having to first lookup every ID, which is helpful when we don't know (or care) about specific IDs (e.g. they are random), but mainly the relationships between objects.

This should be generally helpful when testing replication and tuple mapping.

Local Testing

How can the feature be exercised?
How can the bug be exploited and fix confirmed?
Is any special local setup required?

Checklist

  • if API spec changes are required, is the spec updated?
  • are there any pre/post merge actions required? if so, document here.
  • are theses changes covered by unit tests?
  • if warranted, are documentation changes accounted for?
  • does this require migration changes?
    • if yes, are they backwards compatible?
  • is there known, direct impact to dependent teams/components?
    • if yes, how will this be handled?

Secure Coding Practices Checklist Link

Secure Coding Practices Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

@alechenninger alechenninger force-pushed the testing-via-tuple-traversal branch from 8eefbd7 to b8d18f9 Compare November 9, 2024 15:46
group_filter: Callable[[T], bool] = lambda _: True,
require_full_match: bool = False,
match_once: bool = True,
) -> Tuple[dict[T, "TupleSet"], dict[T, "TupleSet"]]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These methods are just moved from InMemoryTuples.

Basically we reorganized things a little bit so that results from InMemoryTuples return a TupleSet type which can be further filtered. The novelty of this PR is that it adds a traverse_subjects method in this queryset which is not a filter but a traversal.

Comment on lines +205 to +206
traversed = self._full_set.find_tuples(
resource(tuple.subject_type_namespace, tuple.subject_type_name, tuple.subject_id)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The key bit here is that this uses the full set of tuples to search, not just what was filtered in this result set. This result set is just used as the base for traversal (using the resource predicate for each subject in this set).

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.

1 participant