Commit 9bd9155c authored by Patrick van der Leer's avatar Patrick van der Leer
Browse files

removed work class, converted all code to book

parent 4420353b
Pipeline #516 passed with stages
in 1 minute and 18 seconds
......@@ -16,7 +16,7 @@ except FileNotFoundError:
author='Patrick van der Leer',
......@@ -3,7 +3,7 @@ from urllib.parse import urlencode, urlparse, urlunparse
import requests
from solc.exceptions import ArgumentException, EmptyResponseException
from solc.models import Book, Author, Publisher, Work
from solc.models import Book, Author, Publisher
class SimpleOpenLibraryClient(object):
......@@ -122,9 +122,6 @@ class SimpleOpenLibraryClient(object):
# todo: redo this...
if "title" in entry.keys() or (isinstance(type_, str) and ('book' in type_ or 'work' in type_)):
kls = Book
if type_ and 'work' in type_:
kls = Work
if "authors" in entry.keys():
entry['authors'] = [Author(**x) for x in entry['authors']]
if "publishers" in entry.keys():
......@@ -137,7 +134,7 @@ class SimpleOpenLibraryClient(object):
entry['publishers'] = [Publisher(**entry['publishers'])]
return kls(**entry)
return Book(**entry)
if isinstance(type_, str) and 'author' in type_:
return Author(**entry)
if "details" in entry.keys():
......@@ -43,14 +43,3 @@ class Publisher(AbstractContainer):
def __str__(self):
class Work(AbstractContainer):
title: str
subtitle: str
key: any
url: str
def __str__(self):
return self.title
......@@ -2,7 +2,7 @@ import unittest
from solc.client import SimpleOpenLibraryClient
from solc.exceptions import ArgumentException
from solc.models import Book, Author, Work, Publisher
from solc.models import Book, Author, Publisher
class TestClient(unittest.TestCase):
......@@ -14,8 +14,6 @@ class TestClient(unittest.TestCase):
def test_model_to_string(self):
book = Book(title="Test")
self.assertEqual(str(book), "Test")
work = Work(title="Test")
self.assertEqual(str(work), "Test")
author = Author(name="Test")
self.assertEqual(str(author), "Test")
publisher = Publisher(name="Test")
......@@ -44,9 +42,9 @@ class TestClient(unittest.TestCase):
self.assertEqual(book.title, 'Satchidananda Raut Roy')
def test_get_work_by_key(self):
work = self.client.get_work_by_key('OL14930760W')
self.assertIsInstance(work, Work)
self.assertEqual(work.title, 'Satchidananda Raut Roy')
book = self.client.get_work_by_key('OL14930760W')
self.assertIsInstance(book, Book)
self.assertEqual(book.title, 'Satchidananda Raut Roy')
def test_get_book_by_bibkey(self):
with self.assertRaises(ArgumentException):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment