cic-internal-integration/apps/cic-eth/tests/unit/db/test_role.py

30 lines
962 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', init_database) == eth_empty_accounts[0]
2021-02-01 18:12:51 +01:00
bar = AccountRole.set('bar', eth_empty_accounts[1])
init_database.add(bar)
init_database.commit()
assert AccountRole.get_address('bar', init_database) == eth_empty_accounts[1]
2021-02-01 18:12:51 +01:00
foo = AccountRole.set('foo', eth_empty_accounts[2])
init_database.add(foo)
init_database.commit()
assert AccountRole.get_address('foo', init_database) == eth_empty_accounts[2]
assert AccountRole.get_address('bar', init_database) == eth_empty_accounts[1]
2021-02-01 18:12:51 +01:00
tag = AccountRole.role_for(eth_empty_accounts[2])
assert tag == 'foo'
tag = AccountRole.role_for(eth_empty_accounts[3])
assert tag == None