def runTest(self): """ Tests the Role object. """ try: u = User(username='******', fullname='test test', email='*****@*****.**', super_admin=True, disabled=False) PluginChannel(name='test', plugin=Plugin(name='role_plugin', activated='no'), subscription_right='restricted') c = PluginChannel.selectBy(name="test").getOne() r = Role(user=u, channel=c, permission_level=UserPermissions.channel_contributor) assert_true(r != None) assert_true( r.permission_level == UserPermissions.channel_contributor) r.permission_level = UserPermissions.channel_administrator assert_true( r.permission_level == UserPermissions.channel_administrator) Role.delete(r.id) role = Role.selectBy(user=u, channel=c).getOne(None) assert_true(role == None) PluginChannel.delete(c.id) User.delete(u.id) except DuplicateEntryError: assert_true(False)
def channels_1_request(self): # basic test self.testApp.get('/channels/1/request/1', status=303) u = User(username='******', email='*****@*****.**', super_admin=True, disabled=False) self.testApp.get('/channels/1/request/' + str(u.id), status=303) User.delete(u.id)
def runTest(self): """ Tests the User object """ try: User(username='******', fullname='test test', email='*****@*****.**', super_admin=True, disabled=False) except DuplicateEntryError: assert_true(False) b = User.selectBy(username="******").getOne() assert_not_equal(b, None) assert_equal(b.username, "test") try: b.set(username="******") except DuplicateEntryError: assert_true(False) assert_equal(b.username, "newName") b.set(username="******") l = b.get_subscriptions_of_owned_screens() assert_true(l.count() >= 0) una = User(username='******', fullname='testnoadmin test', email='*****@*****.**', super_admin=False, disabled=False) l = una.get_subscriptions_of_owned_screens() assert_true(l.count() >= 0) User.delete(una.id) b.set(disabled=True) assert_equal(b.disabled, True) t = b.owns_screen() assert_equal(t, False) b = User.selectBy(username="******").getOne() b.addScreen(Screen(name='A', building=Building(name='A'))) t = b.owns_screen() assert_equal(t, True) b = User.selectBy(username="******").getOne() t = User.delete(b.id) assert_equal(t, None) b = User.selectBy(username="******").getOne(None) assert_true(None == b)
def runTest(self): """ Tests the cache mecanism. """ u = User(username='******', fullname='testasset test', email='*****@*****.**', super_admin=True, disabled=False) PluginChannel(name='testasset2', plugin=Plugin(name='cache_plugin', activated='no'), subscription_right='restricted') c = PluginChannel.selectBy(name="testasset2").getOne() a = Asset(plugin_channel=c, user=u) self.testApp.get('/cache/' + str(a.id), status=303) try: Asset.delete(a.id) except SQLObjectNotFound: pass finally: User.delete(u.id) PluginChannel.delete(c.id)
def runTest(self): """ Tests the Channel object. """ try: PluginChannel(name='test', plugin=Plugin(name='channel_plugin', activated='no'), subscription_right='restricted') PluginChannel( name='test2', plugin=Plugin.selectBy(name='channel_plugin').getOne(), subscription_right='restricted') c = PluginChannel.selectBy(name="test").getOne() assert_not_equal(None, c) c.set(name="testNew") assert_equal(c.name, "testNew") u = User(username='******', fullname='test test', email='*****@*****.**', super_admin=True, disabled=False) up = UserPermissions.channel_contributor c.give_permission_to_user(u, up) role = Role.selectBy(user=u, channel=c).getOne(None) assert_true(role != None) c.give_permission_to_user(u, up) role = Role.selectBy(user=u, channel=c).getOne(None) assert_true(role != None) getup = c.get_channel_permissions_of(u) assert_equal(getup, up) getupnoperm = c.get_channel_permissions_of(User.get(1)) assert_equal(getupnoperm, UserPermissions.no_permission) c.remove_permission_to_user(u) role = Role.selectBy(user=u, channel=c).getOne(None) assert_true(role == None) assert_false(c.has_admin(u)) up = UserPermissions.channel_administrator c.give_permission_to_user(u, up) assert_true(c.has_admin(u)) assert_true(c.has_contrib(u)) assert_is_not_none(c.get_admins()) assert_is_not_none(c.get_contribs()) assert_in(str(u.id), c.get_users_as_json()) c.remove_permission_to_user(u) role = Role.selectBy(user=u, channel=c).getOne(None) assert_true(role == None) c.give_permission_to_user(None, up) role = Role.selectBy(user=u).getOne(None) assert_true(role == None) tru = c.has_visible_params_for(u) assert_true(tru) u3 = User(username='******', fullname='test3 test2', email='*****@*****.**', super_admin=False, disabled=False) tru = c.has_visible_params_for(u3) assert_false(tru) t = PluginChannel.delete(c.id) assert_equal(t, None) # try to delete a channel used by a screen - Seems to work... sc = Screen(name='A', building=Building(name='A')) sc.subscribe_to(u, PluginChannel.get(2)) # t2 = PluginChannel.delete(2) c4 = PluginChannel.get(2) nbSub = c4.subscriptions.count() c4.set(enabled=False) assert_equal(nbSub, c4.subscriptions.count()) c4.set(enabled=True) c4.set(subscription_right="private") assert_equal(nbSub, c4.subscriptions.count()) c4.set(subscription_right="public") # todo seems working by bypassing the webinterface c4.set(cache_validity=-10) assert_true(c4.cache_validity < 0) sc.unsubscribe_from(u, PluginChannel.get(2)) u2 = User(username='******', fullname='test2 test2', email='*****@*****.**', super_admin=False, disabled=False) l = PluginChannel.get_screens_channels_from(u2) assert_is_not_none(l) temp = PluginChannel.get_visible_channels_of(u2) assert_is_not_none(temp) User.delete(u.id) User.delete(u2.id) User.delete(u3.id) except DuplicateEntryError: assert_true(False) return