Commits

book...@0c1241d1-2811-0410-b6f5-f555c02b9b86  committed d7b113f

Add Similarities, Subjects, Tracks.

  • Participants
  • Parent commits 7cce4b3

Comments (0)

Files changed (2)

 		'SearchBins': ((), (), (), (), {}),
 		'Seller': ((), (), (), (), {}),
 		'SellerListing': ((), (), (), (), {}),
-		'Similarities': ((), (), (), (), {}),
+		'Similarities': ((), (), ('SimilarProducts',), ('SimilarProduct',), {}),
 		'Small': ((), ('ItemAttributes',), (), ('Item',), 
 			{'Items': ('OfferPage', 'TotalResults', 10) }),
-		'Subjects': ((), (), (), (), {}),
+		'Subjects': ((), (), ('Subjects',), ('Subject',), {}),
 		'TopSellers': ((), (), ('TopSellers',), ('TopSeller',), {}),
 		'Tracks': ((), (), (), (), {}),
 		'TransactionDetails': ((), (), ('Transactions', 'TransactionItems', 'Shipments'),
 	"""A generic container for the python objects"""
 	def __repr__(self):
 		return '<Bag instance: ' + self.__dict__.__repr__() + '>'
+	
 
 
 def rawObject(XMLSearch, arguments, kwItem, plugins=None):
 
 	if(rc == None):
 		rc = Bag()
-
+	
 	childElements = [e for e in element.childNodes if isinstance(e, minidom.Element)]
 
 	if childElements:
 		for child in childElements:
 			key = child.tagName
 			if hasattr(rc, key):
-				if type(getattr(rc, key)) <> type([]):
-					setattr(rc, key, [getattr(rc, key)])
+				attr = getattr(rc, key)
+				if type(attr) <> type([]):
+					setattr(rc, key, [attr])
 				setattr(rc, key, getattr(rc, key) + [unmarshal(XMLSearch, arguments, child, plugins)])
 			elif isinstance(child, minidom.Element):
 				if child.tagName in plugins['isCollected']:
 
 if __name__ == "__main__" :
 	setLicenseKey("1MGVS72Y8JF7EC7JDZG2")
-	obj = BrowseNodeLookup("1065852", ResponseGroup='NewReleases,BrowseNodeInfo,TopSellers')
-
-	s = XMLCustomerContentSearch('Manoj Agrawal')
-	print s.toprettyxml()
-
-	s = CustomerContentLookup('A2QT0KPQU671OU', ResponseGroup=','.join(['Request', 'CustomerFull']))
-	import pdb
-	pdb.set_trace()
+	dom = XMLItemLookup('B0000042H4', ResponseGroup='Tracks')
+	print dom.toprettyxml()
+	cds = ItemLookup('B0000042H4', ResponseGroup='Tracks')
+	self.assertEqual(len(cds), 1)
+	cd = cds[0]

File tests/itemlookup.py

 		txs = ecs.ItemLookup('B000BI7NHY', MerchantId='All', Condition='All', ResponseGroup='OfferFull')
 		self.assertEqual(len(txs), 1)
 		tx = txs[0]
-		self.assertEqual(len(tx.Offers), 37)
+		self.assertEqual(len(tx.Offers), 36)
 		
 		# arbitary seller
 		self.assertEqual(tx.Offers[14].Seller.Nickname, 'ravitnus')
-		self.assertEqual(tx.Offers[23].Merchant.MerchantId, 'A2PNJAWEOU5BXV')
+		self.assertEqual(tx.Offers[23].Merchant.MerchantId, 'A16KASCB556RBK')
 
 
 	def testReviews(self):
 		self.assertEqual(book.CustomerReviews[12].Summary, 'An Essential Python Book for Python Programmers')
 
 
+	def testSimilarities(self):
+		books = ecs.ItemLookup(self.ItemId, ResponseGroup='Similarities')
+		self.assertEqual(len(books), 1)
+		book = books[0]
+
+		sim = book.SimilarProducts;
+		self.assertEqual(len(sim), 5)
+		self.assertEqual(sim[0].Title, 'Learning Python, Second Edition')
+		self.assertEqual(sim[1].Title, 'Python Cookbook')
+		self.assertEqual(sim[3].Title, "Python Essential Reference (3rd Edition) (Developer's Library)")
+
+	def testSubjects(self):
+		books = ecs.ItemLookup(self.ItemId, ResponseGroup='Subjects')
+		self.assertEqual(len(books), 1)
+		book = books[0]
+
+		subs = book.Subjects;
+		self.assertEqual(len(subs), 10)
+		self.assertEqual(subs[0], 'Programming languages')
+		self.assertEqual(subs[2], 'Computers')
+
+	def testTracks(self):
+		cds = ecs.ItemLookup('B0000042H4', ResponseGroup='Tracks')
+		self.assertEqual(len(cds), 1)
+		cd = cds[0].Tracks
+		self.assertEqual(len(cd.Disc), 14)
+		self.assertEqual(cd.Disc[13].Track[5], 'Gotterdammerung: Dritter Aufzug, Zweite Szene: Hoiho!')
+		self.assertEqual(cd.Disc[4].Track[3], 'Die Walkure: Zweiter Aufzug, Funfte Szene: Zauberfest bezahmt ein Schlaf der Holden Schmerz und Harm')
+
+
 
 if __name__ == "__main__" :
 	unittest.main()