Exemple #1
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     db.create_all()
     self.user = User(username="******", password="******")
     self.user.save()
     self.token = self.user.generate_auth_token()
Exemple #2
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     db.create_all()
     self.bucketlist = BucketList(name="Travel the World")
     self.bucketlist.user_id = 10
     self.bucketlist.save()
Exemple #3
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     db.create_all()
     self.bucketlist = BucketList(name="Travel the world")
     db.session.add(self.bucketlist)
     self.bucketlist_item = BucketListItem(name="See the great wall")
     self.bucketlist.items.append(self.bucketlist_item)
     self.bucketlist_item.save()
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(BucketListAPI, '/bucketlists',
                                     '/bucketlists/<int:id>',
                                     endpoint='bucketlists')
     db.create_all()
     self.test_client = self.app.test_client()
     self.token = register_a_user(self.test_client, "wahabmalik")
     self.response = post_a_bucketlist(self.test_client, self.token)
Exemple #5
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(BucketListAPI,
                      '/bucketlists',
                      '/bucketlists/<int:id>',
                      endpoint='bucketlists')
     db.create_all()
     self.test_client = self.app.test_client()
     self.token = register_a_user(self.test_client, "wahabmalik")
     self.response = post_a_bucketlist(self.test_client, self.token)
Exemple #6
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(LoginUserAPI, '/auth/login', endpoint='login')
     db.create_all()
     self.body = {
         "username": "******",
         "password": "******",
     }
     self.test_client = self.app.test_client()
     self.response = send_post(self.test_client, '/v1/auth/register',
                               self.body)
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(LoginUserAPI, '/auth/login', endpoint='login')
     db.create_all()
     self.body = {
         "username": "******",
         "password": "******",
       }
     self.test_client = self.app.test_client()
     self.response = send_post(self.test_client, '/v1/auth/register',
                               self.body)
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(BucketListAPI, '/bucketlists',
                                     '/bucketlists/<int:id>',
                                     endpoint='bucketlists')
     api.add_resource(ItemListAPI, '/bucketlists/<int:bucketlist_id>/items',
                      '/bucketlists/<int:bucketlist_id>/items/'
                      '<int:item_id>', endpoint='items')
     db.create_all()
     self.test_client = self.app.test_client()
     self.token = register_a_user(self.test_client, "adeyimalik")
     post_a_bucketlist(self.test_client, self.token)
     self.response = self.post_an_item()
Exemple #9
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
     api.add_resource(BucketListAPI,
                      '/bucketlists',
                      '/bucketlists/<int:id>',
                      endpoint='bucketlists')
     api.add_resource(ItemListAPI,
                      '/bucketlists/<int:bucketlist_id>/items',
                      '/bucketlists/<int:bucketlist_id>/items/'
                      '<int:item_id>',
                      endpoint='items')
     db.create_all()
     self.test_client = self.app.test_client()
     self.token = register_a_user(self.test_client, "adeyimalik")
     post_a_bucketlist(self.test_client, self.token)
     self.response = self.post_an_item()
Exemple #10
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(HelpAPI, '/help', endpoint='help')
     self.test_client = self.app.test_client()
Exemple #11
0
"""Scripts bind API resources with the url to the API instance."""
import os
import sys
import inspect
from flask import jsonify, request, abort, make_response, url_for
from flask_httpauth import HTTPBasicAuth
from bucketlist_api import create_app, api
from bucketlist_api.config import DevConfig
from bucketlist_api.resources.bucketlistapi import BucketListAPI
from bucketlist_api.resources.itemlistapi import ItemListAPI
from bucketlist_api.resources.createuserapi import CreateUserAPI
from bucketlist_api.resources.loginuserapi import LoginUserAPI
from bucketlist_api.resources.helpapi import HelpAPI

# initialization
app = create_app(DevConfig)

api.add_resource(HelpAPI, '/help', endpoint='help')
api.add_resource(CreateUserAPI, '/auth/register', endpoint='register')
api.add_resource(LoginUserAPI, '/auth/login', endpoint='login')
api.add_resource(BucketListAPI,
                 '/bucketlists',
                 '/bucketlists/<int:id>',
                 endpoint='bucketlists')
api.add_resource(ItemListAPI,
                 '/bucketlists/<int:bucketlist_id>/items',
                 '/bucketlists/<int:bucketlist_id>/items/<int:item_id>',
                 endpoint='items')
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app.app_context().push()
     api.add_resource(HelpAPI, '/help', endpoint='help')
     self.test_client = self.app.test_client()
"""Script defines models for the application."""

import os
from flask import Flask, request, jsonify, g, url_for
from sqlalchemy import desc
from datetime import datetime
from passlib.apps import custom_app_context as pwd_context
from bucketlist_api import create_app, db
from bucketlist_api.config import DevConfig
from itsdangerous import (TimedJSONWebSignatureSerializer
                          as Serializer, BadSignature, SignatureExpired)

# initialization
app = create_app(DevConfig)


class BaseModel(db.Model):
    """The base model for implementing features common to all the models.

    Inherits:
        db.Model

    Attributes:
        id: [int] id single model in the database
        date_created: [datetime] date function was created
    """
    __abstract__ = True
    id = db.Column(db.Integer, primary_key=True)
    date_created = db.Column(db.DateTime, default=db.func.now())

    def update(self, commit=True, **kwargs):