cic-stack/apps/cic-eth/tests/unit/db/test_role.py

30 lines
902 B
Python
Raw Normal View History

2021-02-01 18:12:51 +01:00
# local imports
from cic_eth.db.models.role import AccountRole
def test_db_role(
init_database,
eth_empty_accounts,
):
foo = AccountRole.set('foo', eth_empty_accounts[0])
init_database.add(foo)
init_database.commit()
assert AccountRole.get_address('foo') == eth_empty_accounts[0]
bar = AccountRole.set('bar', eth_empty_accounts[1])
init_database.add(bar)
init_database.commit()
assert AccountRole.get_address('bar') == eth_empty_accounts[1]
foo = AccountRole.set('foo', eth_empty_accounts[2])
init_database.add(foo)
init_database.commit()
assert AccountRole.get_address('foo') == eth_empty_accounts[2]
assert AccountRole.get_address('bar') == eth_empty_accounts[1]
tag = AccountRole.role_for(eth_empty_accounts[2])
assert tag == 'foo'
tag = AccountRole.role_for(eth_empty_accounts[3])
assert tag == None