コード例 #1
0
 def test_create_book(self, mock_get):
     book = Book(
         publisher='Karamanolis',
         title='Alles ber Mikrofone',
         identifiers={'isbn_10': ['3922238246']},
         publish_date=1982,
         authors=[Author(name='Karl Schwarzer')],
         publish_location='Neubiberg bei Mnchen',
     )
     author_autocomplete = [{'name': "Karl Schwarzer", 'key': "/authors/OL7292805A"}]
     mock_get.return_value.json.return_value = author_autocomplete
     got_result = self.ol.create_book(book, debug=True)
     mock_get.assert_called_with(
         "{}/authors/_autocomplete?q={}&limit=1".format(
             self.ol.base_url, "Karl Schwarzer"
         )
     )
     expected_result = {
         '_save': '',
         'author_key': '/authors/OL7292805A',
         'author_name': 'Karl Schwarzer',
         'id_name': 'isbn_10',
         'id_value': '3922238246',
         'publish_date': 1982,
         'publisher': 'Karamanolis',
         'title': 'Alles ber Mikrofone',
     }
     self.assertTrue(
         got_result == expected_result,
         "Expected create_book to return %s, got %s" % (expected_result, got_result),
     )
コード例 #2
0
 def test_create_book(self):
     book = Book(publisher=u'Karamanolis',
                 title=u'Alles ber Mikrofone',
                 identifiers={'isbn_10': [u'3922238246']},
                 publish_date=1982,
                 authors=[Author(name=u'Karl Schwarzer')],
                 publish_location=u'Neubiberg bei Mnchen')
     got_result = self.ol.create_book(book, debug=True)
     expected_result = {
         '_save': '',
         'author_key': u'/authors/OL7292805A',
         'author_name': u'Karl Schwarzer',
         'id_name': 'isbn_10',
         'id_value': u'3922238246',
         'publish_date': 1982,
         'publisher': u'Karamanolis',
         'title': u'Alles ber Mikrofone'
     }
     self.assertTrue(got_result == expected_result,
                     "Expected create_book to return %s, got %s" \
                     % (got_result, expected_result))
コード例 #3
0
EXAMPLES_PATH = os.path.abspath(
    os.path.join(
        os.path.join(
            os.path.join(os.path.join(os.path.abspath(__file__), os.pardir),
                         os.pardir),
            'examples',
        ),
        'xisbn',
    ))

example_path = lambda filename: os.path.join(EXAMPLES_PATH, filename)

XISBN_BOOKS = [
    Book(
        authors=[Author(name='Carl Bridenbaugh.')],
        cover='',
        identifiers={
            'isbn_10': ['0689705344'],
            'lccn': ['78152044'],
            'oclc':
            ['4128493', '466349680', '6066278', '730964000', '803233939'],
        },
        language='eng',
        pages=None,
        publish_date='1976',
        publisher='Atheneum',
        subtitle='',
        title=
        'Fat mutton and liberty of conscience : society in Rhode Island, 1636-1690',
    ),
コード例 #4
0
import os
import unittest

from olclient.common import Book, Author

EXAMPLES_PATH = os.path.abspath(
    os.path.join(
        os.path.join(
            os.path.join(os.path.join(os.path.abspath(__file__), os.pardir),
                         os.pardir), u'examples'), u'xisbn'))

example_path = lambda filename: os.path.join(EXAMPLES_PATH, filename)

XISBN_BOOKS = [
    Book(
        authors=[Author(name=u'Carl Bridenbaugh.')],
        cover='',
        identifiers={
            'isbn_10': [u'0689705344'],
            'lccn': [u'78152044'],
            'oclc':
            [u'4128493', u'466349680', u'6066278', u'730964000', u'803233939']
        },
        language=u'eng',
        pages=None,
        publish_date=u'1976',
        publisher=u'Atheneum',
        subtitle=u'',
        title=
        u'Fat mutton and liberty of conscience  society in Rhode Island 16361690'
    ),