Example #1
0
File: tests.py Project: kosc/neobug
def add_issue(app, project_num, title, body, csrf_token, project_id):
    return app.post('/projects/'+str(project_num), data=dict(
        project_id=project_id,
        status='New',
        category='Bug',
        title=title,
        body=body,
        csrf_token=csrf_token
    ), follow_redirects=True)


def get_csrf_token(app, token_for):
    rv = app.get('/' + token_for)
    html = lxml.html.document_fromstring(rv.data)
    return html.get_element_by_id('csrf_token').value

if __name__ == '__main__':
    if len(User.objects(username='******')) == 0:
        """We need to add test user only for first test run"""
        app = neobug.test_client()
        token = get_csrf_token(app, 'register')
        register(app, 'test', '*****@*****.**', 'proverka', token)
        token = get_csrf_token(app, 'projects/new')
        add_project(app, 'Test project', 'Test project description', token)
        project = Project.objects(name='Test project')[0]
        project_num = project.number
        project_id = project.id
        token = get_csrf_token(app, 'projects/' + str(project_num))
        add_issue(app, project_num, 'Test issue', 'Test issue body', token, project_id)
    unittest.main()
Example #2
0
File: tests.py Project: kosc/neobug
 def setUp(self):
     self.app = neobug.test_client()
Example #3
0
 def setUp(self):
     self.app = neobug.test_client()