Files
status-go/test/functional/tests/test_token_preferences.py
Igor Sirotin b7ba8e52d6 refactor: move test suites under test/
tests-functional/    -> test/functional/
  tests-unit-network/  -> test/unit-network/

No Go code changes beyond the two package paths. Every reference follows:
Makefile targets, the pytest-lint and reliability workflows, the three
Jenkinsfiles, the root Dockerfile, pyrightconfig.json, .gitignore, the
benchmark and functional-test scripts, and the docs.

All paths inside the moved directories are self-contained (docker compose
uses `context: .`, the Python helpers resolve from __file__), so the extra
level of nesting does not reach outside.

refs #7067
2026-08-20 20:59:45 +02:00

60 lines
3.0 KiB
Python

import pytest
@pytest.mark.rpc
class TestTokenPreferences:
@pytest.fixture()
def backend(self, backend_new_profile):
return backend_new_profile("account-backend")
def test_update_with_valid_token_preferences(self, backend):
token_preferences_before = backend.accounts_service.get_token_preferences()
assert token_preferences_before is None
new_token_preferences = [
{"communityId": "123", "groupPosition": 2, "key": "0x1234567890abcdef1234567890abcdef12345678", "position": 3, "visible": True}
]
update_response = backend.accounts_service.update_token_preferences(new_token_preferences)
assert update_response is None
token_preferences_after = backend.accounts_service.get_token_preferences()
assert token_preferences_after == new_token_preferences
def test_update_with_invalid_token_preferences(self, backend):
new_token_preferences = [{"key": "0x1234567890abcdef1234567890abcdef12345678", "foo": "bar"}]
backend.accounts_service.update_token_preferences(new_token_preferences)
token_preferences_after = backend.accounts_service.get_token_preferences()
assert len(token_preferences_after)
# missing fields are assigned default values
# extra fields are ignored
# exiting fields are updated
token_preference = token_preferences_after[0]
assert token_preference.get("communityId") == ""
assert token_preference.get("groupPosition") == 0
assert token_preference.get("key") == new_token_preferences[0]["key"]
assert token_preference.get("position") == 0
assert token_preference.get("visible") is False
def test_overwrite_existing_token_preferences(self, backend):
new_token_preferences1 = [
{"communityId": "123", "groupPosition": 2, "key": "0x1234567890abcdef1234567890abcdef12345678", "position": 3, "visible": True}
]
backend.accounts_service.update_token_preferences(new_token_preferences1)
new_token_preferences2 = [
{"communityId": "567", "groupPosition": 1, "key": "0x1234567890abcdef1234567890abcdef12345676", "position": 1, "visible": False}
]
backend.accounts_service.update_token_preferences(new_token_preferences2)
token_preferences_after = backend.accounts_service.get_token_preferences()
assert token_preferences_after == new_token_preferences2
def test_add_multiple_token_preferences(self, backend):
new_token_preferences = [
{"communityId": "123", "groupPosition": 2, "key": "0x1234567890abcdef1234567890abcdef12345678", "position": 3, "visible": True},
{"communityId": "567", "groupPosition": 1, "key": "0x1234567890abcdef1234567890abcdef12345676", "position": 1, "visible": False},
]
backend.accounts_service.update_token_preferences(new_token_preferences)
token_preferences_after = backend.accounts_service.get_token_preferences()
assert token_preferences_after == new_token_preferences