def test_ownerfilter_nouser(): # UserContext(user_session) user_session = {} user_session['user_context'] = 1 f = UserContext(user_session) assert f.context == 1 assert f.owner_str() == 'Isotammi database' user_session['user_context'] = 2 assert f.context == 1 assert f.owner_str() == 'Isotammi database', "No user gets wrong data"
def test_ownerfilter_user_selection(user_env): ''' Example: - Show all my data / div=2 - with common data / cmp=1 <Request 'http://127.0.0.1:5000/scene/persons_all/?div=2&cmp=1' [GET]> <User Session {'_fresh': True, '_id': '...', 'csrf_token': '...', 'lang': 'en', 'next_person': ['', '>'], 'user_context': 2, 'user_id': 'juha'}> ''' user_session, current_user, request = user_env f = UserContext(user_session, current_user, request) assert f.context == 1 assert f.owner_str() == 'Isotammi database' x = f.use_owner_filter() assert x == False, "use_owner_filter() failed" x = f.use_common() assert x == True, "use_common() failed"