def test_retrieve(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, asynchronous=False) rate = rates.results[0] retrieve = shippo.Rate.retrieve(rate.object_id) self.assertItemsEqual(rate, retrieve)
def test_retrieve(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates( shipment.object_id, asynchronous=False) rate = rates.results[0] retrieve = shippo.Rate.retrieve(rate.object_id) self.assertItemsEqual(rate, retrieve)
def test_create(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, asynchronous=False) rate = rates.results[0] TRANSACTION = DUMMY_TRANSACTION.copy() TRANSACTION['rate'] = rate.object_id transaction = shippo.Transaction.create(**TRANSACTION) self.assertEqual(transaction.object_state, 'VALID')
def test_create(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, async=False) rate = rates.results[0] TRANSACTION = DUMMY_TRANSACTION.copy() TRANSACTION['rate'] = rate.object_id transaction = shippo.Transaction.create(**TRANSACTION) self.assertEqual(transaction.object_state, 'VALID')
def test_invalid_add(self): BATCH = DUMMY_BATCH.copy() batch = shippo.Batch.create(**BATCH) self.assertEqual(batch.status, 'VALIDATING') mock_shipment = create_mock_shipment() self.assertRaises(shippo.error.APIError, shippo.Batch.add, 'INVALID_OBJECT_KEY', [{ 'shipment': [mock_shipment] }])
def test_retrieve(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, async=False) rate = rates.results[0] TRANSACTION = DUMMY_TRANSACTION.copy() TRANSACTION['rate'] = rate.object_id transaction = shippo.Transaction.create(**TRANSACTION) retrieve = shippo.Transaction.retrieve(transaction.object_id) self.assertItemsEqual(transaction, retrieve)
def test_get_rates(self): try: shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, async=False) except shippo.error.InvalidRequestError: pass except shippo.error.AuthenticationError: self.fail('Set your SHIPPO_API_KEY in your os.environ') except Exception as inst: self.fail("Test failed with exception %s" % inst) self.assertTrue('results' in rates)
def test_get_rates(self): try: shipment = create_mock_shipment() rates = shippo.Shipment.get_rates( shipment.object_id, asynchronous=False) except shippo.error.InvalidRequestError: pass except shippo.error.AuthenticationError: self.fail('Set your SHIPPO_API_KEY in your os.environ') except Exception as inst: self.fail("Test failed with exception %s" % inst) self.assertTrue('results' in rates)
def test_add(self): BATCH = DUMMY_BATCH.copy() batch = shippo.Batch.create(**BATCH) # Leave enough time for the batch to be processed retrieve = shippo.Batch.retrieve(batch.object_id) batch_size = len(retrieve.batch_shipments.results) self.assertEqual(batch.status, 'VALIDATING') addon = [] for i in range(BATCH_ADD_SIZE): mock_shipment = create_mock_shipment() addon.append({'shipment': mock_shipment.object_id}) added = shippo.Batch.add(batch.object_id, addon) added_size = len(added.batch_shipments.results) self.assertEqual(batch_size + len(addon), added_size)
def test_get_rate(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id) self.assertTrue('results' in rates)
def test_get_rate(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id) self.assertTrue('count' in rates) self.assertTrue('results' in rates)
def test_retrieve(self): shipment = create_mock_shipment() retrieve = shippo.Shipment.retrieve(shipment.object_id) self.assertItemsEqual(shipment, retrieve)
def test_create(self): shipment = create_mock_shipment() self.assertEqual(shipment.object_state, 'VALID')
def test_create(self): shipment = create_mock_shipment() self.assertEqual(shipment.status, 'SUCCESS')
def test_get_rates_blocking(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, async=False) self.assertTrue('count' in rates) self.assertTrue('results' in rates)
def test_get_rates_blocking(self): shipment = create_mock_shipment() rates = shippo.Shipment.get_rates(shipment.object_id, asynchronous=False) self.assertTrue('results' in rates)