-
Notifications
You must be signed in to change notification settings - Fork 4
Double down on human readable fixtures and support via extended hints. #349
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
Open
albu-diku
wants to merge
2
commits into
next
Choose a base branch
from
test/fixture-date-hints
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"/C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=test@example.com": { | ||
"full_name": "Test User", | ||
"organization": "Test Org", | ||
"state": "NA", | ||
"country": "DK", | ||
"email": "test@example.com", | ||
"comment": "This is the create comment", | ||
"password": "", | ||
"password_hash": "PBKDF2$sha256$10000$XMZGaar/pU4PvWDr$w0dYjezF6JGtSiYPexyZMt3lM2134uix", | ||
"distinguished_name": "/C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=test@example.com", | ||
"locality": "", | ||
"organizational_unit": "", | ||
"expire": { | ||
"_FixtureHint": true, | ||
"hint": "today_relative", | ||
"modifier": "days|+5", | ||
"value": 0 | ||
}, | ||
"created": 1759921716.5731237, | ||
"unique_id": "8txp5j0lxVL5xiWp0N4pxzeswIVWlkEuqubucyubWiSaSGZeH0bZDbHQr46FQoBT", | ||
"openid_names": [] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ONWRITE] | ||
convert_dict_bytes_to_strings_kv = True |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's a great idea to have the dynamics and logic embedded directly in the json 🤔 or if it would in fact be better to simply have a dumb replacement marker (e.g.
__EXPIRE__
) there and require it to always be actively expanded by the unit tests when using the fixture.Alternatively going all-in and (re)use e.g. jinja2 templating and have these known dynamic values filled by the engine.
The main point would be to actually keep all logic contained in the tests rather than spreading it across fixtures and tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this too but concluded differently. There is still a distinct separation here: the fixture data specifies exactly what ought to be the case when it is loaded, and tests only see the resultant structure. In addition, I need this in the data itself rather than in the test so that it can be used for e.g. writing a test user database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of the latest push you can see the effect of this here:
https://github.com/ucphhpc/migrid-sync/pull/349/files#diff-fed3248b2c06db6ed9ddce22baba29d9a62e32d47cb2b596e19d4b1d867d97c1R376
The JSON on-disk fixture is used as the basis of the pickled user database consumed by other things. This actually ends up working really well because if any changes to that basic user are required, you simply edit the fixture.