Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_address_unicode():
# Create an address with unicode field and assert if it was created correctly.
state = u'DELEGACI\xf3N BENITO JU\xe1REZ'
address = easypost.Address.create(state=state)
assert address.state == state
def test_batch_create_and_buy():
# We create Address and Parcel objects. We then try to create a Batch containing a shipment. Finally,
# Finally, we assert on saved and returned data.
# from address and parcel don't change
from_address = easypost.Address.create(
name='Simpler Postage Inc.',
street1='388 Townsend St',
street2='Apt 20',
city='San Francisco',
state='CA',
zip='94107',
phone='415-456-7890'
)
parcel = easypost.Parcel.create(
predefined_package='RegionalRateBoxA',
weight=64
)
# # populate order_list from db, csv, etc.
order_list = [{
def test_shipment_creation():
# We create a shipment and assert on values saved.
# create a to address and a from address
to_address = easypost.Address.create(
name="Sawyer Bateman",
street1="1A Larkspur Cres.",
street2="",
city="St. Albert",
state="AB",
zip="t8n2m4",
country="CA",
phone="780-283-9384"
)
from_address = easypost.Address.create(
company="EasyPost",
street1="118 2nd St",
street2="4th Fl",
city="San Francisco",
state="CA",
zip="94105",
phone="415-456-7890"
)
# create a parcel
parcel = easypost.Parcel.create(
length=10.2,
width=7.8,
height=4.3,
weight=21.2
)
def test_shipment_creation():
# We create a shipment and assert on values saved.
# create a to address and a from address
to_address = easypost.Address.create(
name="Sawyer Bateman",
street1="1A Larkspur Cres.",
street2="",
city="St. Albert",
state="AB",
zip="t8n2m4",
country="CA",
phone="780-283-9384"
)
from_address = easypost.Address.create(
company="EasyPost",
street1="118 2nd St",
street2="4th Fl",
city="San Francisco",
state="CA",
zip="94105",
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# create address
address = easypost.Address.create(
company="EasyPost",
street1="118 2nd St",
street2="4th Fl",
city="San Francisco",
state="CA",
zip="94105",
phone="415-456-7890"
)
verified_address = address.verify()
print(verified_address)
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# easypost.api_base = 'http://localhost:5000/v2'
# create addresses
to_address = easypost.Address.create(
name="Sawyer Bateman",
street1="1A Larkspur Cres.",
street2="",
city="St. Albert",
state="AB",
zip="t8n2m4",
country="CA",
phone="780-283-9384"
)
from_address = easypost.Address.create(
company="EasyPost",
street1="118 2nd St",
street2="4th Fl",
city="San Francisco",
state="CA",
zip="94105",
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# unicode
state = u'DELEGACI\xf3N BENITO JU\xe1REZ'
address = easypost.Address.create(state=state)
assert address.state == state
# bytestring
address = easypost.Address.create(state=state.encode('utf-8'))
assert address.state == state
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# easypost.api_base = 'http://localhost:5000/v2'
# create addresses
to_address = easypost.Address.create(
name="Sawyer Bateman",
street1="1A Larkspur Cres.",
street2="",
city="St. Albert",
state="AB",
zip="t8n2m4",
country="CA",
phone="780-283-9384"
)
from_address = easypost.Address.create(
company="EasyPost",
street1="118 2nd St",
street2="4th Fl",
city="San Francisco",
state="CA",
zip="94105",
phone="415-456-7890"
)
# verify address
try:
verified_from_address = from_address.verify()
except easypost.Error as e:
raise e
if hasattr(verified_from_address, 'message'):
# the from address is not invalid, but it has an issue
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# unicode
state = u'DELEGACI\xf3N BENITO JU\xe1REZ'
address = easypost.Address.create(state=state)
assert address.state == state
# bytestring
address = easypost.Address.create(state=state.encode('utf-8'))
assert address.state == state
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
try:
# this request will raise an error
address = easypost.Address.create(
verify_strict=["delivery"],
street1="UNDELIEVRABLE ST",
city="San Francisco",
state="CA",
zip="94105",
country="US",
company="EasyPost",
phone="415-456-7890"
)
except easypost.Error as e:
print(e.http_body)