Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/fixture/MiG-users.db--example.json
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": []
}
}
2 changes: 2 additions & 0 deletions tests/fixture/MiG-users.db--example.json.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ONWRITE]
convert_dict_bytes_to_strings_kv = True
187 changes: 0 additions & 187 deletions tests/fixture/MiG-users.db--example.pickle

This file was deleted.

2 changes: 1 addition & 1 deletion tests/fixture/mig_shared_configuration--new.json.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DEFAULT]
[ATTRIBUTES]
auto_add_user_permit = array_of_tuples
auto_add_user_with_peer = array_of_tuples
site_cloud_access = array_of_tuples
Expand Down
7 changes: 6 additions & 1 deletion tests/fixture/peer_user_dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"comment": "test@example.com",
"locality": "",
"organizational_unit": "",
"expire": 1758970812,
"expire": {
"_FixtureHint": true,
"hint": "today_relative",
"modifier": "days|+5",
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

"value": 0
},
"created": 1727434813.0792377,
"openid_names": [],
"distinguished_name": "/C=DK/ST=NA/L=NA/O=Test Org/OU=NA/CN=Test User/emailAddress=peer@example.com"
Expand Down
Loading