diff options
| author | Max Nanis | 2026-03-06 16:49:46 -0500 |
|---|---|---|
| committer | Max Nanis | 2026-03-06 16:49:46 -0500 |
| commit | 91d040211a4ed6e4157896256a762d3854777b5e (patch) | |
| tree | cd95922ea4257dc8d3f4e4cbe8534474709a20dc /tests/models/thl/test_product_userwalletconfig.py | |
| download | generalresearch-91d040211a4ed6e4157896256a762d3854777b5e.tar.gz generalresearch-91d040211a4ed6e4157896256a762d3854777b5e.zip | |
Initial commitv3.3.4
Diffstat (limited to 'tests/models/thl/test_product_userwalletconfig.py')
| -rw-r--r-- | tests/models/thl/test_product_userwalletconfig.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/models/thl/test_product_userwalletconfig.py b/tests/models/thl/test_product_userwalletconfig.py new file mode 100644 index 0000000..4583c46 --- /dev/null +++ b/tests/models/thl/test_product_userwalletconfig.py @@ -0,0 +1,56 @@ +from itertools import groupby +from random import shuffle as rshuffle + +from generalresearch.models.thl.product import ( + UserWalletConfig, +) + +from generalresearch.models.thl.wallet import PayoutType + + +def all_equal(iterable): + g = groupby(iterable) + return next(g, True) and not next(g, False) + + +class TestProductUserWalletConfig: + + def test_init(self): + instance = UserWalletConfig() + + assert isinstance(instance, UserWalletConfig) + + # Check the defaults + assert not instance.enabled + assert not instance.amt + + assert isinstance(instance.supported_payout_types, set) + assert len(instance.supported_payout_types) == 3 + + assert instance.min_cashout is None + + def test_model_dump(self): + instance = UserWalletConfig() + + # If we use the defaults, the supported_payout_types are always + # in the same order because they're the same + assert isinstance(instance.model_dump_json(), str) + res = [] + for idx in range(100): + res.append(instance.model_dump_json()) + assert all_equal(res) + + def test_model_dump_payout_types(self): + res = [] + for idx in range(100): + + # Generate a random order of PayoutTypes each time + payout_types = [e for e in PayoutType] + rshuffle(payout_types) + instance = UserWalletConfig.model_validate( + {"supported_payout_types": payout_types} + ) + + res.append(instance.model_dump_json()) + + assert all_equal(res) |
