Exemple #1
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
     self.user = {
         'user_email': '*****@*****.**',
         'user_name': 'Kaynyts000',
         'user_password': '******'
     }
     self.usertwo = {
         'user_email': '*****@*****.**',
         'user_name': 'Kaynuts000',
         'user_password': '******'
     }
     self.business = {
         'business_name': 'MTN',
         'location': 'Kampala',
         'category': 'Telecomm',
         'business_profile': 'Best Telecomm Company'
     }
     self.review = {
         "review_title": "Best Telecomm Company",
         "review_msg": "Telecommunications"
     }
     db.session.remove()
     db.drop_all()
     db.create_all()
Exemple #2
0
 def __init__(self, business_name, business_profile,\
              location, category, user_id):
     self.business_name = business_name
     self.business_profile = business_profile
     self.location = location
     self.category = category
     self.user_id = user_id
     db.create_all()
Exemple #3
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
     db.session.remove()
     db.drop_all()
     db.create_all()
     self.user = {
         'user_email': '*****@*****.**',
         'user_name': 'sonjaYXG',
         'user_password': '******'
     }
     self.user_two = {
         'user_email': '*****@*****.**',
         'user_name': 'Kaynyts000',
         'user_password': '******'
     }
Exemple #4
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
     db.session.remove()
     db.drop_all()
     db.create_all()
     self.user = {'user_email' : '*****@*****.**', 'user_name': 'Kaynuts000', 
                 'user_password' : 'qWerty123'}
     self.user_two = {'user_email' : '*****@*****.**', 'user_name': 'Kaynyts000', 
                     'user_password' : '12345678'}
     self.business = {'business_name': 'MTN Kla', 'location' : 'Kampala', 'category' : 'Telecomm', 
                      'business_profile': 'Best Telecomm Company'}
     self.business_edit = {'business_name': 'MTN-Uganda', 'location' : 'Kampala',
                           'category' : 'Telecommunications', 'business_profile': 'Best Telecomm Company'}
     self.business_edit_duplicate = {'business_name': 'MTN Kawempe', 
                                     'location' : 'Kampala', 'category' : 'Telecomm', 
                                     'business_profile': 'Best Telecomm Company'}
     self.business_two = {'business_name': 'MTN Kawempe', 'location' : 'Kampala', 
                          'category' : 'Telecomm', 'business_profile': 'Best Telecomm Company'}
Exemple #5
0
    def post(self):
        '''
        COMPLETELY resets the database (!!!WARNING!!!)
        '''
        try:
            db.drop_all()
            db.create_all()
            # add default admin user
            db.session.add(
                User(username='******',
                     password='******',
                     is_admin=True,
                     email='*****@*****.**',
                     access_time=int(time())))
            db.session.commit()
        except:
            db.session.rollback()
            raise ServiceUnavailable('Database error')

        return make_response({'status': 'OK'})
Exemple #6
0
 def __init__(self, token):
     self.token = token
     db.create_all()
Exemple #7
0
def create_table():
    db.create_all()
Exemple #8
0
 def setUp(self):
     super(BaseTestCase, self).setUp()
     db.create_all()
     self.session = db.session
Exemple #9
0
 def __init__(self, review_title, review_msg, business_id, user_id):
     self.review_title = review_title
     self.review_msg = review_msg
     self.business_id = business_id
     self.user_id = user_id
     db.create_all()
Exemple #10
0
        destination = "/".join([target, _productImage])
        print("File saved to to:", destination)
        file.save(destination)

        Product.update_product(id, _name, _amount, _category, _description, _productImage)
        response = Response("Product Updated", status=200, mimetype='application/json')
        return response

    res = make_response(jsonify({"error": "Incorrect Product Id"}), 404)
    return res

# Deleting products based on id
@app.route('/product/<int:id>', methods=['DELETE'])
def remove_product(id):
    if Product.check_id(id) :
        Product.delete_product(id)
        response = Response("Product Deleted", status=200, mimetype='application/json')
        return response

    res = make_response(jsonify({"error": "Incorrect Product Id"}), 404)
    return res  

# To navigate to specific image in folder 
@app.route('/static/images/<filename>')
def send_image(filename):
    return send_from_directory("static/images", filename)
    

if __name__ == "__main__":
    db.create_all()     
    app.run()
Exemple #11
0
 def __init__(self, user_email, user_name, user_password):
     self.user_email = user_email
     self.user_name = user_name
     self.user_password = generate_password_hash(user_password, method='sha256')
     db.create_all()