def test_24_get_specific_completed_task_user(self): """Test WEB get specific completed task_id for an app works as an user""" model.rebuild_db() Fixtures.create() self.register() user = model.Session.query(model.User)\ .filter(model.User.name=='johndoe')\ .first() app = model.Session.query(model.App).first() task = model.Session.query(model.Task)\ .filter(model.App.id==app.id)\ .first() for i in range(10): task_run = model.TaskRun(app_id=app.id, task_id=task.id, user_id=user.id, info={'answer':1}) model.Session.add(task_run) model.Session.commit() #self.app.get('api/app/%s/newtask' % app.id) ntask = model.Task(id=task.id,state='completed') #self.signin() assert ntask not in model.Session model.Session.merge(ntask) model.Session.commit() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'You have already participated in this task' in res.data, res.data assert 'Try with another one' in res.data, res.data self.signout()
def test_20_admin_add_category(self): """Test ADMIN add category works""" Fixtures.create() category = {'name': 'cat', 'short_name': 'cat', 'description': 'description'} # Anonymous user url = '/admin/categories' res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Authenticated user but not admin self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be added" assert "Category added" in res.data, err_msg assert category['name'] in res.data, err_msg
def test_20_admin_add_category(self): """Test ADMIN add category works""" Fixtures.create() category = {"name": "cat", "short_name": "cat", "description": "description"} # Anonymous user url = "/admin/categories" res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id="signin") is not None, err_msg # Authenticated user but not admin self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be added" assert "Category added" in res.data, err_msg assert category["name"] in res.data, err_msg category = {"name": "cat", "short_name": "cat", "description": "description"} self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category form validation should work" assert "Please correct the errors" in res.data, err_msg
def test_25_get_wrong_task_app(self): """Test WEB get wrong task.id for an app works""" model.rebuild_db() Fixtures.create() app1 = db.session.query(model.App).get(1) app1_short_name = app1.short_name db.session.query(model.Task)\ .filter(model.Task.app_id == 1)\ .first() self.register() self.new_application() app2 = db.session.query(model.App).get(2) self.new_task(app2.id) task2 = db.session.query(model.Task)\ .filter(model.Task.app_id == 2)\ .first() task2_id = task2.id self.signout() res = self.app.get('/app/%s/task/%s' % (app1_short_name, task2_id)) assert "Error" in res.data, res.data assert "This task does not belong to %s" % app1_short_name\ in res.data, res.data
def test_22_get_specific_completed_task_anonymous(self): """Test WEB get specific completed task_id for an app works as anonymous""" model.rebuild_db() Fixtures.create() app = model.Session.query(model.App).first() task = model.Session.query(model.Task)\ .filter(model.App.id==app.id)\ .first() for i in range(10): task_run = model.TaskRun(app_id=app.id, task_id=task.id, user_ip="127.0.0.1", info={'answer':1}) model.Session.add(task_run) model.Session.commit() ntask = model.Task(id=task.id,state='completed') assert ntask not in model.Session model.Session.merge(ntask) model.Session.commit() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'You have already participated in this task' in res.data, res.data assert 'Try with another one' in res.data, res.data
def test_22_get_specific_completed_task_anonymous(self): """Test WEB get specific completed task_id for an app works as anonymous""" model.rebuild_db() Fixtures.create() app = db.session.query(model.App).first() task = db.session.query(model.Task)\ .filter(model.App.id == app.id)\ .first() for i in range(10): task_run = model.TaskRun(app_id=app.id, task_id=task.id, user_ip="127.0.0.1", info={'answer': 1}) db.session.add(task_run) db.session.commit() ntask = model.Task(id=task.id, state='completed') assert ntask not in db.session db.session.merge(ntask) db.session.commit() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'You have already participated in this task'\ in res.data, res.data assert 'Try with another one' in res.data, res.data
def test_22_admin_delete_category(self): """Test ADMIN delete category works""" Fixtures.create() obj = db.session.query(model.Category).get(2) category = obj.dictize() # Anonymous user GET url = "/admin/categories/del/%s" % obj.id res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id="signin") is not None, err_msg # Anonymous user POST res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id="signin") is not None, err_msg # Authenticated user but not admin GET self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg # Authenticated user but not admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin GET self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.get(url, follow_redirects=True) err_msg = "Category should be listed for admin user" assert category["name"] in res.data, err_msg # Admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be deleted" assert "Category deleted" in res.data, err_msg assert category["name"] not in res.data, err_msg output = db.session.query(model.Category).get(obj.id) assert output is None, err_msg # Non existant category category["id"] = 5000 url = "/admin/categories/del/5000" res = self.app.post(url, data=category, follow_redirects=True) assert res.status_code == 404, res.status_code # Now try to delete the only available Category obj = db.session.query(model.Category).first() url = "/admin/categories/del/%s" % obj.id category = obj.dictize() res = self.app.post(url, data=category, follow_redirects=True) print res.data err_msg = "Category should not be deleted" assert "Category deleted" not in res.data, err_msg assert category["name"] in res.data, err_msg output = db.session.query(model.Category).get(obj.id) assert output.id == category["id"], err_msg
def test_22_admin_delete_category(self): """Test ADMIN delete category works""" Fixtures.create() obj = db.session.query(model.Category).get(2) category = obj.dictize() # Anonymous user GET url = '/admin/categories/del/%s' % obj.id res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Anonymous user POST res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Authenticated user but not admin GET self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg # Authenticated user but not admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin GET self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.get(url, follow_redirects=True) err_msg = "Category should be listed for admin user" assert category['name'] in res.data, err_msg # Admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be deleted" assert "Category deleted" in res.data, err_msg assert category['name'] not in res.data, err_msg output = db.session.query(model.Category).get(obj.id) assert output is None, err_msg # Non existant category category['id'] = 5000 url = '/admin/categories/del/5000' res = self.app.post(url, data=category, follow_redirects=True) assert res.status_code == 404, res.status_code # Now try to delete the only available Category obj = db.session.query(model.Category).first() url = '/admin/categories/del/%s' % obj.id category = obj.dictize() res = self.app.post(url, data=category, follow_redirects=True) print res.data err_msg = "Category should not be deleted" assert "Category deleted" not in res.data, err_msg assert category['name'] in res.data, err_msg output = db.session.query(model.Category).get(obj.id) assert output.id == category['id'], err_msg
def test_incremental_tasks(self): """ Test incremental SCHED strategy - second TaskRun receives first gaven answer""" Fixtures.create_2(sched='incremental') # Del previous TaskRuns self.del_task_runs() # Register self.register(fullname=self.user.fullname, username=self.user.username, password=self.user.password) self.register(fullname="Marie Doe", username="******", password="******") self.signin() # Get the only task with no runs! res = self.app.get('api/app/1/newtask') data = json.loads(res.data) # Check that we received a clean Task assert data.get('info'), data assert not data.get('info').get('last_answer') # Submit an Answer for the assigned task tr = dict(app_id=data['app_id'], task_id=data['id'], info={'answer': 'No'}) tr = json.dumps(tr) self.app.post('/api/taskrun', data=tr) # No more tasks available for this user! res = self.app.get('api/app/1/newtask') data = json.loads(res.data) assert not data #### Get the only task now with an answer as Anonimous! self.signout() res = self.app.get('api/app/1/newtask') data = json.loads(res.data) # Check that we received a Task with answer assert data.get('info'), data assert data.get('info').get('last_answer').get('answer') == 'No' # Submit a second Answer as Anonimous tr = dict(app_id=data['app_id'], task_id=data['id'], info={'answer': 'No No'}) tr = json.dumps(tr) self.app.post('/api/taskrun', data=tr) #### Get the only task now with an answer as User2! self.signin(email="*****@*****.**", password="******") res = self.app.get('api/app/1/newtask') data = json.loads(res.data) # Check that we received a Task with answer assert data.get('info'), data assert data.get('info').get('last_answer').get('answer') == 'No No'
def setUp(self): model.rebuild_db() self.root, self.user1, self.user2 = Fixtures.create_users() self.app = Fixtures.create_app('') self.app.owner = self.root db.session.add(self.app) db.session.commit() self.task = model.Task(app_id=self.app.id, state='0', n_answers=10) self.task.app = self.app db.session.add(self.task) db.session.commit()
def test_29_tutorial_anonymous_user(self): """Test WEB app without tutorials work as an anonymous user""" Fixtures.create() db.session.commit() self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" not in res.data, "There should not be a tutorial for the application" # Second time should give me a task, and not the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" not in res.data
def test_21_get_specific_ongoing_task_anonymous(self): """Test WEB get specific ongoing task_id for an app works as anonymous""" Fixtures.create() self.delTaskRuns() app = db.session.query(model.App).first() task = db.session.query(model.Task).filter(model.App.id == app.id).first() res = self.app.get("app/%s/task/%s" % (app.short_name, task.id), follow_redirects=True) assert "TaskPresenter" in res.data, res.data assert "?next=%2Fapp%2F" + app.short_name + "%2Ftask%2F" + str(task.id), res.data
def test_29_tutorial_anonymous_user(self): """Test WEB app without tutorials work as an anonymous user""" Fixtures.create() db.session.commit() self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" not in res.data,\ "There should not be a tutorial for the application" # Second time should give me a task, and not the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" not in res.data
def test_23_get_specific_ongoing_task_user(self): """Test WEB get specific ongoing task_id for an app works as an user""" Fixtures.create() self.delTaskRuns() self.register() self.signin() app = db.session.query(model.App).first() task = db.session.query(model.Task).filter(model.App.id == app.id).first() res = self.app.get("app/%s/task/%s" % (app.short_name, task.id), follow_redirects=True) assert "TaskPresenter" in res.data, res.data self.signout()
def test_28_non_tutorial_signed_user(self): """Test WEB app without tutorial work as signed in user""" Fixtures.create() model.Session.commit() self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" not in res.data,\ "There should not be a tutorial for the application" # Second time should give me a task, and not the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" not in res.data
def test_21_get_specific_ongoing_task_anonymous(self): """Test WEB get specific ongoing task_id for an app works as anonymous""" Fixtures.create() self.delTaskRuns() app = model.Session.query(model.App).first() task = model.Session.query(model.Task)\ .filter(model.App.id==app.id)\ .first() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'TaskPresenter' in res.data, res.data
def test_26_tutorial_signed_user(self): """Test WEB tutorials work as signed in user""" Fixtures.create() app1 = db.session.query(model.App).get(1) app1.info = dict(tutorial="some help") db.session.commit() self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" in res.data, "There should be some tutorial for the application" # Second time should give me a task, and not the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" not in res.data
def test_21_get_specific_ongoing_task_anonymous(self): """Test WEB get specific ongoing task_id for an app works as anonymous""" Fixtures.create() self.delTaskRuns() app = db.session.query(model.App).first() task = db.session.query(model.Task)\ .filter(model.App.id == app.id)\ .first() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'TaskPresenter' in res.data, res.data
def test_06_featured_apps(self): """Test WEB application index shows featured apps in all the pages works""" Fixtures.create() f = model.Featured() f.app_id=1 db.session.add(f) db.session.commit() res = self.app.get('/app', follow_redirects=True) assert self.html_title("Applications") in res.data, res.data assert "Applications" in res.data, res.data assert '/app/test-app' in res.data, res.data assert '<h2> <i class="icon-star"></i><a href="/app/test-app">My New App</a></h2>' in res.data, res.data
def test_21_admin_update_category(self): """Test ADMIN update category works""" Fixtures.create() obj = db.session.query(model.Category).get(1) _name = obj.name category = obj.dictize() # Anonymous user GET url = '/admin/categories/update/%s' % obj.id res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Anonymous user POST res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Authenticated user but not admin GET self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg # Authenticated user but not admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin GET self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.get(url, follow_redirects=True) err_msg = "Category should be listed for admin user" assert _name in res.data, err_msg # Check 404 url_404 = '/admin/categories/update/5000' res = self.app.get(url_404, follow_redirects=True) assert res.status_code == 404, res.status_code # Admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be updated" assert "Category updated" in res.data, err_msg assert category['name'] in res.data, err_msg updated_category = db.session.query(model.Category).get(obj.id) assert updated_category.name == obj.name, err_msg # With not valid form category['name'] = None res = self.app.post(url, data=category, follow_redirects=True) assert "Please correct the errors" in res.data, err_msg
def test_27_tutorial_anonymous_user(self): """Test WEB tutorials work as an anonymous user""" Fixtures.create() app1 = db.session.query(model.App).get(1) app1.info = dict(tutorial="some help") db.session.commit() self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" in res.data,\ "There should be some tutorial for the application" # Second time should give me a task, and not the tutorial res = self.app.get('/app/test-app/newtask', follow_redirects=True) assert "some help" not in res.data
def test_21_admin_update_category(self): """Test ADMIN update category works""" Fixtures.create() obj = db.session.query(model.Category).get(1) _name = obj.name category = obj.dictize() # Anonymous user GET url = "/admin/categories/update/%s" % obj.id res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id="signin") is not None, err_msg # Anonymous user POST res = self.app.post(url, data=category, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id="signin") is not None, err_msg # Authenticated user but not admin GET self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.post(url, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg # Authenticated user but not admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin GET self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.get(url, follow_redirects=True) err_msg = "Category should be listed for admin user" assert _name in res.data, err_msg # Check 404 url_404 = "/admin/categories/update/5000" res = self.app.get(url_404, follow_redirects=True) assert res.status_code == 404, res.status_code # Admin POST res = self.app.post(url, data=category, follow_redirects=True) err_msg = "Category should be updated" assert "Category updated" in res.data, err_msg assert category["name"] in res.data, err_msg updated_category = db.session.query(model.Category).get(obj.id) assert updated_category.name == obj.name, err_msg # With not valid form category["name"] = None res = self.app.post(url, data=category, follow_redirects=True) assert "Please correct the errors" in res.data, err_msg
def test_18_admin_delete_tasks(self): """Test ADMIN can delete an app's tasks that belongs to another user""" # Admin Fixtures.create() tasks = db.session.query(model.Task).filter_by(app_id=1).all() assert len(tasks) > 0, "len(app.tasks) > 0" res = self.signin(email=u"*****@*****.**", password=u"tester" + "root") res = self.app.get("/app/test-app/tasks/delete", follow_redirects=True) err_msg = "Admin user should get 200 in GET" assert res.status_code == 200, err_msg res = self.app.post("/app/test-app/tasks/delete", follow_redirects=True) err_msg = "Admin should get 200 in POST" assert res.status_code == 200, err_msg tasks = db.session.query(model.Task).filter_by(app_id=1).all() assert len(tasks) == 0, "len(app.tasks) != 0"
def test_18_admin_delete_tasks(self): """Test ADMIN can delete an app's tasks that belongs to another user""" # Admin Fixtures.create() tasks = db.session.query(model.Task).filter_by(app_id=1).all() assert len(tasks) > 0, "len(app.tasks) > 0" res = self.signin(email=u'*****@*****.**', password=u'tester' + 'root') res = self.app.get('/app/test-app/tasks/delete', follow_redirects=True) err_msg = "Admin user should get 200 in GET" assert res.status_code == 200, err_msg res = self.app.post('/app/test-app/tasks/delete', follow_redirects=True) err_msg = "Admin should get 200 in POST" assert res.status_code == 200, err_msg tasks = db.session.query(model.Task).filter_by(app_id=1).all() assert len(tasks) == 0, "len(app.tasks) != 0"
def test_27_tutorial_anonymous_user(self): """Test WEB tutorials work as an anonymous user""" Fixtures.create() app1 = db.session.query(model.App).get(1) app1.info = dict(tutorial="some help") db.session.commit() # self.register() # First time accessing the app should redirect me to the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" in res.data, "There should be some tutorial for the application" assert ( "?next=%2Fapp%2Ftest-app%2Ftutorial" in res.data ), "There should be a link to Sign in and redirect to tutorial" # Second time should give me a task, and not the tutorial res = self.app.get("/app/test-app/newtask", follow_redirects=True) assert "some help" not in res.data
def test_06_applications(self): """Test WEB applications index interface works""" # Check first without apps res = self.app.get('/app', follow_redirects=True) assert "Applications" in res.data, res.data assert "Featured" in res.data, res.data assert "Published" in res.data, res.data assert "Draft" in res.data, res.data assert "Create an application!" in res.data, res.data Fixtures.create() res = self.app.get('/app', follow_redirects=True) assert self.html_title("Applications") in res.data, res.data assert "Applications" in res.data, res.data assert '/app/test-app' in res.data, res.data
def test_19_admin_list_categories(self): """Test ADMIN list categories works""" Fixtures.create() # Anonymous user url = '/admin/categories' res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Anonymous users should be redirected to sign in" assert dom.find(id='signin') is not None, err_msg # Authenticated user but not admin self.signin(email=Fixtures.email_addr2, password=Fixtures.password) res = self.app.get(url, follow_redirects=True) err_msg = "Non-Admin users should get 403" assert res.status_code == 403, err_msg self.signout() # Admin user self.signin(email=Fixtures.root_addr, password=Fixtures.root_password) res = self.app.get(url, follow_redirects=True) dom = BeautifulSoup(res.data) err_msg = "Admin users should be get a list of Categories" assert dom.find(id='categories') is not None, err_msg
def test_24_get_specific_completed_task_user(self): """Test WEB get specific completed task_id for an app works as an user""" model.rebuild_db() Fixtures.create() self.register() user = db.session.query(model.User)\ .filter(model.User.name == 'johndoe')\ .first() app = db.session.query(model.App).first() task = db.session.query(model.Task)\ .filter(model.App.id == app.id)\ .first() for i in range(10): task_run = model.TaskRun(app_id=app.id, task_id=task.id, user_id=user.id, info={'answer': 1}) db.session.add(task_run) db.session.commit() #self.app.get('api/app/%s/newtask' % app.id) ntask = model.Task(id=task.id, state='completed') #self.signin() assert ntask not in db.session db.session.merge(ntask) db.session.commit() res = self.app.get('app/%s/task/%s' % (app.short_name, task.id), follow_redirects=True) assert 'You have already participated in this task'\ in res.data, res.data assert 'Try with another one' in res.data, res.data self.signout()
def setUp(self): super(TestHateoas, self).setUp() Fixtures.create()
def setup_class(cls): Fixtures.create_account() config['download_cache_directory'] = 'test/data/downloads' # initialise the plugins ingest.init() assert 'bibtex' in ingest.PLUGINS
def setUp(self): super(TestI18n, self).setUp() Fixtures.create()
def setUp(self): web.app.config['ENFORCE_PRIVACY'] = False self.app = web.app.test_client() model.rebuild_db() Fixtures.create()
def setUp(self): self.app = web.app.test_client() model.rebuild_db() Fixtures.create() self.endpoints = ['app', 'task', 'taskrun']
def setUp(self): super(TestCkanWeb, self).setUp() Fixtures.create()
def setUp(self): self.app = web.app.test_client() model.rebuild_db() Fixtures.create()
def test_get_breadth_first_task_user(self): user = Fixtures.create_users()[0] self._test_get_breadth_first_task(user)
def setup_class(cls): Fixtures.create_account()
def setup_class(cls): cls.app = web.app.test_client() model.rebuild_db() Fixtures.create()
def setUp(self): self.app = web.app model.rebuild_db() Fixtures.create()
def setUp(self): model.rebuild_db() Fixtures.create()
class TestTokenAuthorization: auth_providers = ('twitter', 'facebook', 'google') root, user1, user2 = Fixtures.create_users() def test_anonymous_user_delete(self): """Test anonymous user is not allowed to delete an oauth token""" token_authorization.current_user = FakeCurrentUser() for token in self.auth_providers: assert not token_authorization.delete(token) def test_authenticated_user_delete(self): """Test authenticated user is not allowed to delete an oauth token""" token_authorization.current_user = FakeCurrentUser(self.root) for token in self.auth_providers: assert not token_authorization.delete(token) def test_anonymous_user_create(self): """Test anonymous user is not allowed to create an oauth token""" token_authorization.current_user = FakeCurrentUser() for token in self.auth_providers: assert not token_authorization.create(token) def test_authenticated_user_create(self): """Test authenticated user is not allowed to create an oauth token""" token_authorization.current_user = FakeCurrentUser(self.root) for token in self.auth_providers: assert not token_authorization.create(token) def test_anonymous_user_update(self): """Test anonymous user is not allowed to update an oauth token""" token_authorization.current_user = FakeCurrentUser() for token in self.auth_providers: assert not token_authorization.update(token) def test_authenticated_user_update(self): """Test authenticated user is not allowed to update an oauth token""" token_authorization.current_user = FakeCurrentUser(self.root) for token in self.auth_providers: assert not token_authorization.update(token) def test_anonymous_user_read(self): """Test anonymous user is not allowed to read an oauth token""" token_authorization.current_user = FakeCurrentUser() for token in self.auth_providers: assert not token_authorization.read(token) def test_authenticated_user_read(self): """Test authenticated user is allowed to read his own oauth tokens""" token_authorization.current_user = FakeCurrentUser(self.root) for token in self.auth_providers: assert token_authorization.read(token)
def create_categories(self): categories = db.session.query(model.Category).all() if len(categories) == 0: print "Categories 0" print "Creating default ones" Fixtures.create_categories()
def setUp(self): super(TestSched, self).setUp() model.rebuild_db() Fixtures.create() self.endpoints = ['app', 'task', 'taskrun']
def setUp(self): super(TestSched, self).setUp() Fixtures.create() self.endpoints = ['app', 'task', 'taskrun']