def test_create_client_should_accept_email(): user = factories.UserFactory() assert not amodels.Client.select().count() createclient(name='test client', user=user.email) assert amodels.Client.select().count() == 1 client = amodels.Client.first() assert client.user == user
def test_create_client_with_contributor_types(monkeypatch): monkeypatch.setattr('ban.commands.helpers.prompt', lambda *x, **wk: 'ign laposte') user = factories.UserFactory() createclient(name='test client', user=user.username, scopes=['test']) client = amodels.Client.first() assert client.contributor_types == ['ign', 'laposte', 'viewer']
def test_create_client_without_scopes(monkeypatch): monkeypatch.setattr('ban.commands.helpers.prompt', lambda *x, **wk: '') user = factories.UserFactory() createclient(name='test client', user=user.username, contributor_types=['develop']) client = amodels.Client.first() assert client.scopes == []
def test_create_client_should_accept_email(): user = factories.UserFactory() assert not amodels.Client.select().count() createclient(name='test client', user=user.email, scopes=['test'], contributor_types=['develop']) assert amodels.Client.select().count() == 1 client = amodels.Client.first() assert client.user == user
def test_create_client_should_not_crash_on_non_existing_user(capsys): assert not amodels.Client.select().count() createclient(name='test client', user='******') assert not amodels.Client.select().count() out, err = capsys.readouterr() assert 'User not found' in out