def test_basic_shopify_methods(self): """ Non-connection tests :return: """ fake_creds = dict( SHOPIFY_KEY='incorrect_value', SHOPIFY_PASSWORD='******', SHOPIFY_STORE='incorrect_value', SHOPIFY_BASE_URL='incorrect_value', ) s = Shopify(fake_creds) for call, count in prepare_call_tests: self.assertEqual( len(s.prepare_call(call)), count, )
from shopify import Shopify NAME = 'ledbury' DISPLAY_NAME = 'Ledbury - Apparel' cats = ['new-shirts', 'dress-shirts', 'business-casual', 'casual-sport', 'sunday-shirting', 'all-clothing', 'blazers', 'sweaters', 'pants', 'ties', 'cold-weather-accessories', 'collar-stays', 'cufflinks-studs', 'pocket-squares', 'the-tuxedo-capsule'] cat_names = ['New Shirts', 'Dress Shirts', 'Busienss Casual', 'Casual + Sport', 'Sunday Shirting', 'All Clothing', 'Sports Coats', 'Sweaters + Knits', 'Pants'] shipping = 'Free shipping and returns for all orders above $125' note = 'Final upload' brand = Shopify(NAME, DISPLAY_NAME, cats, shipping, note) brand.run() brand.write_csv() brand.write_info() # brand.post_collections(cat_names)
from app import db from models import Discount from flask import Blueprint, render_template, request from shopify import Shopify shopify = Shopify() api_module = Blueprint('api', __name__, url_prefix='/api') @api_module.route('/generate', methods=['POST']) def generate_discount(): if request.method == 'POST': discount = Discount(**request.form.to_dict()) shopify.add_discount(discount) db.session.add(discount) db.session.commit() return render_template('index.html', code=discount.code)