def client(): _client = view.app.test_client() auth_service = MagicMock() event_service = MagicMock() test_user1 = User(1, 'test', 'test', 'test') test_user2 = User(2, 'test', 'test', 'test') test_user1.auth = Authorisation(1, 'test', '5f4dcc3b5aa765d61d8327deb882cf99', []) test_user2.auth = Authorisation(1, 'test', '5f4dcc3b5aa765d61d8327deb882cf99', []) auth_service.authenticate = MagicMock(return_value=test_user1) auth_service.add = MagicMock(return_value=test_user2) auth_service.change_password = MagicMock(return_value=test_user2) project = Project(1, 1, 'test name', 'test description') events = [AnalyticalEvent(1, datetime.now(), 'test', 'test', 'test', 1)] event_service.add_project = MagicMock(return_value=project.id) event_service.change_project_name = MagicMock(return_value=project.id) event_service.change_project_description = MagicMock( return_value=project.id) event_service.get_all_projects = MagicMock(return_value=[project]) event_service.get_project = MagicMock(return_value=project) event_service.get_all_events = MagicMock(return_value=[e for e in events]) event_service.add_event = MagicMock(return_value=1) view.event_service = event_service view.auth_service = auth_service return _client
def sign_in(): form = SignInForm() if form.validate_on_submit(): email = form.email.data password = form.password.data #authenticate the user try: User.auth(email, password) # Sign in successful flash( 'User {}, logged in with id={}'.format(current_user.email, current_user.id), 'blue') return redirect(url_for('main.index')) except Exception as e: # Sign in unsuccessful error_json = e.args[1] error = json.loads(error_json)['error']['message'] flash("Error: {}".format(error), 'red') return render_template('auth/sign_in.html', title='Sign In', form=form) return render_template('auth/sign_in.html', title='Sign In', form=form)
def test_membership_invite(team, user, password): role = "READ" membership = Membership.create(user.id, team.id, role) assert membership.user_id == user.id assert membership.team_id == team.id assert membership.role == role user = User.auth('*****@*****.**', password) assert user.email == '*****@*****.**' print("") membership.remove()
def test_sign_in(user, password): user = User.auth('*****@*****.**', password) assert user.email == '*****@*****.**'