Example #1
0
 def test_github_api_expansion(self):
     template = purl.Template(
         'https://api.github.com/repos/codeinthehole/purl/labels{/name}')
     url = template.expand()
     self.assertEquals(
         'https://api.github.com/repos/codeinthehole/purl/labels',
         url.as_string())
Example #2
0
def upload_release_asset(release_id, token, file_path: Path):
    upload_url = hammock("https://api.github.com/repos/dortania/build-repo/releases/" + str(release_id), auth=("github-actions", token)).GET().json()
    upload_url = upload_url["upload_url"]
    mime_type = mime.from_file(str(file_path.resolve()))
    if not mime_type[0]:
        print("Failed to guess mime type!")
        return False

    asset_upload = hammock(str(purl.Template(upload_url).expand({"name": file_path.name, "label": file_path.name})), auth=("github-actions", token)).POST(
        data=file_path.read_bytes(),
        headers={"content-type": mime_type}
    )
    return asset_upload.json()["browser_download_url"]
Example #3
0
 def test_basic_expansion(self):
     template = purl.Template('http://example.com{+path,x}/here')
     url = template.expand({'path': '/foo/bar', 'x': 1024})
     self.assertEquals('http://example.com/foo/bar,1024/here',
                       url.as_string())
import pprint

from django.conf import settings
import json
import purl
import requests

from . import models, exceptions

__all__ = ['get_tax', 'post_tax']

logger = logging.getLogger('avalara')

# URL templates
URL_TEMPLATES = {
    'get_tax': purl.Template('{/version}/tax{/location}/get{?saleamount}'),
    'post_tax': purl.Template('{/version}/tax/get'),
}


def fetch(method, url_template, url_params=None, payload=None):
    """
    Make a HTTP round-trip to Avalara
    """
    # Build URL
    if url_params is None:
        url_params = {}
    url_params['version'] = '1.0'
    url = url_template.expand(url_params)
    host = 'avatax.avalara.net'
    if getattr(settings, 'AVALARA_TEST_MODE', False):
from django.conf import settings
import json
import purl
import requests

from avalara_integration import models, exceptions

# __all__ = ['get_tax', 'post_tax']
__all__ = ['post_tax',]

logger = logging.getLogger('avalara')

# URL templates
URL_TEMPLATES = {
    'post_tax': purl.Template('/api{/version}/transactions/create'),
}

AVALARA_API_VERSION = 'v2'

def fetch(method, url_template, url_params=None, payload=None):
    """
    Make a HTTP round-trip to Avalara
    """
    # Build URL
    if url_params is None:
        url_params = {}
    url_params['version'] = AVALARA_API_VERSION
    url = url_template.expand(url_params)
    host = settings.AVALARA_ENDPOINT
    url = url.scheme('https').host(host).as_string()
Example #6
0
def have_a_template(step, template):
    world.template = purl.Template(template)