def setUp(self): '''sets up the test client''' self.app = createapp(os.getenv('APP_SETTINGS')) self.client = self.app.test_client() self.app_context = self.app.app_context() with self.app.app_context(): drop_tables() create_tables() # variables for the user endpoints; # including but not limited to: logging in and signing up self.valid_entry = { "firstname": "solo", "lastname": "compredo", "othername": "nyakahia", "email": "*****@*****.**", "phoneNumber": "0723143761", "username": "******", "password": "******" }
def setUp(self): self.app = createapp() self.client = self.app.test_client self.database_name = "fun_api" self.database_path = getenv('DATABASE_URL', None) # setupdb(self.app, self.database_path) with self.app.app_context(): self.db = SQLAlchemy() self.db.init_app(self.app) self.app.config['SQLALCHEMY_DATABASE_URI'] = self.database_path self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False self.db.app = self.app self.endptheader = { 'Authorization': 'Bearer {}'.format(accesstoken_endpointcheck) } self.adminheaders = { 'Authorization': 'Bearer {}'.format(accesstoken_adminuser) } self.generalheaders = { 'Authorization': 'Bearer {}'.format(accesstoken_generaluser) }
from flask_frozen import Freezer from flask import json from app import createapp import collections if __name__ == '__main__': app = createapp() freezer = Freezer(app) data = json.load(app.open_resource('data.json'), object_pairs_hook=collections.OrderedDict) @freezer.register_generator def product_url_generator(): # Return a list. (Any iterable type will do.) paths = ['/', '/en-US/'] for k, p in data["source"].iteritems(): for lang in p['lang']: paths.append('/' + lang + '/' + k + '.html') print paths return paths freezer.freeze()
from flask_frozen import Freezer from flask import json from app import createapp; import collections if __name__ == '__main__': app = createapp() freezer = Freezer(app) data = json.load(app.open_resource('data.json'), object_pairs_hook=collections.OrderedDict) @freezer.register_generator def product_url_generator(): # Return a list. (Any iterable type will do.) paths = [ '/', '/en-US/' ] for k, p in data["source"].iteritems(): for lang in p['lang']: paths.append('/'+lang+'/'+k+'.html') print paths return paths freezer.freeze()
def setUp(self): self.app = createapp() self.client = self.app.test_client() self.office1 = {"type": "Member of Paliament", "name": "MP Nairobi"} self.erroroffice = {}
import os from app import createapp config_name = os.getenv('APP_SETTINGS') app = createapp(config_name) if __name__ == '__main__': app.run(debug= 1)
def setUp(self): self.app = createapp() self.client = self.app.test_client() self.party1 = {"name": "Part Theo", "logoUrl": ""} self.partytodelete = {"name": "Party 230", "logoUrl": ""} self.invalidparty = {"_id": 1}