def test_is_moderator(): user = User(id=1, name="test", first_name="utilisateur", email="*****@*****.**") db.session.add(user) u = User.query.get(1) assert is_moderator(u) == False a= Authorization(channel_id=1,user_id=1,permission=2) db.session.add(a) assert is_moderator(u) == True
def test_channels_available_for_user(): u = User.query.get(1) assert len(channels_available_for_user(u.id)) == 1 user = User(id=3, name="test", first_name="utilisateur3", email="*****@*****.**") db.session.add(user) assert len(channels_available_for_user(user.id)) == 0
def test_get_moderate_channels_for_user(): u = User.query.get(1) channel = Channel(name="test", module=get_module_full_name("mail"), config="{}") db.session.add(channel) assert get_moderate_channels_for_user(u) is not None user = User(id=2, name="test", first_name="utilisateur2", email="*****@*****.**") db.session.add(user) assert len(get_moderate_channels_for_user(user)) == 0 a = Authorization(channel_id=1, user_id=2, permission=2) db.session.add(a) assert len(get_moderate_channels_for_user(user)) == 1
def test_search_unlogged_client_publishing_search(client): user = User(id=6, name="test", first_name="utilisateur", email="*****@*****.**") db.session.add(user) channel = Channel(name="test", module=get_module_full_name("TestTwitter"), config="{}") db.session.add(channel) a = Authorization(channel_id=1, user_id=6, permission=2) db.session.add(a) r = requests.post("http://127.0.0.1:5000/search_publishings", { "subject": "", "body": "", "author": "", "channels": "test" }) assert int(r.status_code) == 403
def test_not_moderator(client) : user = User(id=1, name="test", first_name="utilisateur", email="*****@*****.**") db.session.add(user) channel = Channel(name="test", module=get_module_full_name("TestTwitter"), config="{}") db.session.add(channel) login(client, 1) r = requests.post("http://127.0.0.1:5000/search_publishings", { "subject": "", "body": "", "author": "", "channels": "test" }) assert r.status_code == 403
def test_channels_available_for_user(): u = User.query.get(63) #assert len(channels_available_for_user(u.id))==1 #TEAM6: MODIFICATION FOR PDF CHANNELS AVAILABLE FOR EVERY USER #u = User.query.get(1) pdf_channels = db.session.query(Channel).filter( Channel.module == "superform.plugins.pdf") pdf_channels_number = 0 if (pdf_channels is not None): for chan in pdf_channels: pdf_channels_number += 1 assert len(channels_available_for_user(u.id)) == 1 + pdf_channels_number user = User(id=3, name="test", first_name="utilisateur3", email="*****@*****.**") db.session.add(user) assert len(channels_available_for_user(user.id)) == 0 + pdf_channels_number
def create_user(id, name, first_name, email): user = User(id=id, name=name, first_name=first_name, email=email) write_to_db(user) return user