3
from tests.unit import unittest
11
simple = os.environ.get('MWS_MERCHANT', None)
14
Please set the MWS_MERCHANT environmental variable
15
to your Merchant or SellerId to enable MWS tests.
21
if __name__ == "__main__":
22
devpath = os.path.relpath(os.path.join('..', '..'),
23
start=os.path.dirname(__file__))
24
sys.path = [devpath] + sys.path
25
advanced = simple and True or False
27
print '>>> advanced MWS tests; using local boto sources'
29
from boto.mws.connection import MWSConnection
32
class MWSTestCase(unittest.TestCase):
35
self.mws = MWSConnection(Merchant=simple, debug=0)
37
@unittest.skipUnless(simple and isolator, "skipping simple test")
38
def test_feedlist(self):
39
self.mws.get_feed_submission_list()
41
@unittest.skipUnless(simple and isolator, "skipping simple test")
42
def test_inbound_status(self):
43
response = self.mws.get_inbound_service_status()
44
status = response.GetServiceStatusResult.Status
45
self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED'))
48
def marketplace(self):
49
response = self.mws.list_marketplace_participations()
50
result = response.ListMarketplaceParticipationsResult
51
return result.ListMarketplaces.Marketplace[0]
54
def marketplace_id(self):
55
return self.marketplace.MarketplaceId
57
@unittest.skipUnless(simple and isolator, "skipping simple test")
58
def test_marketplace_participations(self):
59
response = self.mws.list_marketplace_participations()
60
result = response.ListMarketplaceParticipationsResult
61
self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId)
63
@unittest.skipUnless(simple and isolator, "skipping simple test")
64
def test_get_product_categories_for_asin(self):
66
response = self.mws.get_product_categories_for_asin(\
67
MarketplaceId=self.marketplace_id,
69
result = response._result
70
self.assertTrue(int(result.Self.ProductCategoryId) == 21)
72
@unittest.skipUnless(simple and isolator, "skipping simple test")
73
def test_list_matching_products(self):
74
response = self.mws.list_matching_products(\
75
MarketplaceId=self.marketplace_id,
77
products = response._result.Products
78
self.assertTrue(len(products))
80
@unittest.skipUnless(simple and isolator, "skipping simple test")
81
def test_get_matching_product(self):
83
response = self.mws.get_matching_product(\
84
MarketplaceId=self.marketplace_id,
86
product = response._result[0].Product
89
@unittest.skipUnless(simple and isolator, "skipping simple test")
90
def test_get_lowest_offer_listings_for_asin(self):
92
response = self.mws.get_lowest_offer_listings_for_asin(\
93
MarketplaceId=self.marketplace_id,
96
product = response._result[0].Product
97
self.assertTrue(product.LowestOfferListings)
99
if __name__ == "__main__":