def test_validate_tx_id_with_invalid_tx_id(): """Tests that a ValidationError is thrown when tx_id isn't a valid UUID""" with app.app_context(): form = StoreForm() form.tx_id.data = "abc" with pytest.raises(ValidationError) as excinfo: form.validate_tx_id(form, form.tx_id) assert 'Invalid UUID.' in str(excinfo.value)
def test_validate_tx_id_with_invalid_tx_id(): """Tests that a ValidationError is thrown when tx_id isn't a valid UUID""" with app.app_context(): form = StoreForm() form.tx_id.data = "abc" with pytest.raises(ValidationError) as excinfo: form.validate_tx_id(form, form.tx_id) assert 'Invalid UUID.' in str(excinfo.value)
def test_validate_password_no_number(): """Tests that a ValidationError is thrown when a password has no numbers in it""" with app.app_context(): form = NewUserForm() form.email.data = "*****@*****.**" form.password.data = "ABCDabcd" with pytest.raises(ValidationError) as excinfo: form.validate_password(form, form.password) assert 'password should have atleast one number' in str(excinfo.value)
def init_db(schema): oldcwd = os.getcwd() os.chdir(os.path.dirname(os.path.realpath(__file__))) with app.app_context(): db = get_db() with app.open_resource(schema, mode="r") as f: db.cursor().executescript(f.read()) db.commit() os.chdir(oldcwd)
def test_validate_password_no_lowercase(): """Tests that a ValidationError is thrown when a password has no lower case characters in it""" with app.app_context(): form = NewUserForm() form.email.data = "*****@*****.**" form.password.data = "ABCD1234" with pytest.raises(ValidationError) as excinfo: form.validate_password(form, form.password) assert 'password should have atleast one lowercase character' in str( excinfo.value)
def setUp(self): self.app = server.app.test_client() self.app.testing = True self.render_templates = False self.postgresql = Postgresql() console.settings.DB_URI = self.postgresql.url() app.config['SQLALCHEMY_DATABASE_URI'] = console.settings.DB_URI with app.app_context(): db.create_all() create_initial_users() db.session.commit()
def submit_test_responses(): responses_json = get_test_data() with app.app_context(): for response in responses_json: tx_id = response['tx_id'] invalid = False data = response response_data = SurveyResponse(tx_id=tx_id, invalid=invalid, data=data) db.session.merge(response_data) db.session.commit()
def setUp(self): self.app = server.app.test_client() self.app.testing = True self.render_templates = False self.postgresql = Postgresql() console.settings.DB_URI = self.postgresql.url() app.config['SQLALCHEMY_DATABASE_URI'] = console.settings.DB_URI with app.app_context(): db.create_all() create_initial_users() db.session.commit()
def submit_test_responses(): responses_json = get_test_data() with app.app_context(): for response in responses_json: tx_id = response['tx_id'] invalid = False data = response response_data = SurveyResponse(tx_id=tx_id, invalid=invalid, data=data) db.session.merge(response_data) db.session.commit()