Exemplo n.º 1
0
 def testTracks(self):
     cds = ecs.ItemSearch('Gotterdammerung',
                          SearchIndex='Classical',
                          ResponseGroup='Tracks')
     cd = cds[1].Tracks
     self.assertEqual(len(cd.Disc), 2)
     self.assertEqual(cd.Disc[0].Track[5],
                      'The Rheingold: Journey Down To Nibelheim')
     self.assertEqual(cd.Disc[1].Track[3], 'Parsifal: Good Friday Music')
Exemplo n.º 2
0
 def testAccessories(self):
     # We have to use Palm Tungsten X
     items = ecs.ItemSearch('Zen',
                            SearchIndex='Electronics',
                            ResponseGroup='Small,Accessories')
     for i in range(20):
         try:
             self.assertAccessories(items[i])
         except IndexError:
             pass
Exemplo n.º 3
0
 def testLarge(self):
     items = ecs.ItemSearch('XML Python',
                            SearchIndex='Books',
                            ResponseGroup='Large')
     self.assertTrue(items)
     for i in range(20):
         try:
             self.assertLarge(items[i])
         except IndexError:
             pass
Exemplo n.º 4
0
 def testMedium(self):
     items = ecs.ItemSearch("XML Python",
                            SearchIndex="Books",
                            ResponseGroup='Request,Medium')
     self.assertTrue(items)
     for i in range(20):
         try:
             self.assertMedium(items[i])
         except IndexError:
             pass
Exemplo n.º 5
0
    def testSubjects(self):
        books = ecs.ItemSearch('XML Python',
                               SearchIndex='Books',
                               MerchantId='All',
                               ResponseGroup='Subjects')
        book = books[0]

        subs = book.Subjects
        self.assert_('HTML' in subs)
        self.assert_('Computers' in subs)
        self.assert_('Programming Languages - Perl' in subs)
Exemplo n.º 6
0
    def testReviews(self):
        books = ecs.ItemSearch('XML Python',
                               SearchIndex='Books',
                               MerchantId='All',
                               ResponseGroup='Reviews')
        book = books[4]
        self.assert_(len(book.CustomerReviews) > 10)

        # arbitary reviewer
        self.assertEqual(book.CustomerReviews[3].Reviewer.Name, 'M. Bennett')
        self.assertEqual(book.CustomerReviews[10].Summary, 'Nice followup')
Exemplo n.º 7
0
 def testOfferFull(self):
     items = ecs.ItemSearch('XML Python',
                            SearchIndex='Books',
                            MerchantId='All',
                            ResponseGroup='OfferFull')
     self.assertTrue(items)
     for i in range(20):
         try:
             self.assertOfferFull(items[i])
         except IndexError:
             pass
Exemplo n.º 8
0
    def testSimilarities(self):
        books = ecs.ItemSearch('XML Python',
                               SearchIndex='Books',
                               MerchantId='All',
                               ResponseGroup='Similarities')
        book = books[0]

        sim = book.SimilarProducts
        self.assertEqual(len(sim), 5)
        self.assertEqual(
            sim[0].Title,
            'Professional JavaScript for Web Developers (Wrox Professional Guides)'
        )
        self.assertEqual(
            sim[1].Title,
            'Professional Ajax, 2nd Edition (Programmer to Programmer)')
        self.assertEqual(sim[3].Title, 'Ajax in Action')
Exemplo n.º 9
0
 def setUp(self):
     # prepare the python books to add
     self.books = ecs.ItemSearch("python", SearchIndex="Books")
     self.cart = None
Exemplo n.º 10
0
 def testItemSearch(self):
     books = ecs.ItemSearch("", Title="Python", SearchIndex="Books")
     self.assert_(
         len(books) > 200,
         "We are expect more than 200 books are returned.")
     self.assertNotEqual(books[100], None)
Exemplo n.º 11
0
    if (searchLocale != "us"):
        searchMode = "Books-" + searchLocale

    for searchField in fields:

        if (searchLocale != "" and searchField != ""):
            collection = doc.createElement("List")
            collection.setAttribute("name", "Amazon Import")
            root.appendChild(collection)

            pythonBooks = None

            if searchField == "authors":
                pythonBooks = ecs.ItemSearch('',
                                             Author=query,
                                             SearchIndex=searchMode)
            elif searchField == "asin":
                pythonBooks = ecs.ItemLookup(query)
            else:
                pythonBooks = ecs.ItemSearch('',
                                             Title=query,
                                             SearchIndex=searchMode)

            for book in pythonBooks:
                try:
                    bookElement = doc.createElement("Book")
                    # book = ecs.ItemLookup(book.ASIN)[0]

                    bookElement.setAttribute("title", book.Title)
Exemplo n.º 12
0
from pprint import pprint
import ecs


def get_infos(books):
    book_info = dict()
    for book in books:
        book_info[book.ASIN] = dict()
        for mtd in dir(book):
            if mtd[0] != '_':
                book_info[book.ASIN][mtd] = eval('book.%s' % mtd)
    return book_info


if __name__ == "__main__":
    ecs.setLicenseKey('0J356Z09CN88KB743582')
    #books = ecs.ItemSearch('python', SearchIndex='Books')
    books = ecs.ItemSearch(
        '0465027814',
        SearchIndex='Books',
        ResponseGroup=
        'TagsSummary,Tags,ItemAttributes,EditorialReview,Images,Similarities,PromotionalTag'
    )
    pprint(get_infos(books))