Ejemplo n.º 1
0
    def test_parse_isbn13_response(self):
        xml_string = get_file_as_string('tests/fixtures/book_by_isbn.xml')
        foo = parse_isbn13_response(xml_string)

        assert foo == (1417331, None, None, 'My Book Title',
                       'http://some.fake.gltd/fake.png', '1975', '457', '4.13',
                       'Fake Author', None)
Ejemplo n.º 2
0
    def test_admin_getshelves_post(self, monkeypatch):
        monkeypatch.setattr("sorter.__main__.DB_NAME", "")
        monkeypatch.setattr("sorter.__main__.page_vars", lambda *args: (1,2,3,4))
        monkeypatch.setattr("sorter.__main__.read_url", lambda *args: get_file_as_string('tests/fixtures/shelf_list.xml'))

        middleware = []
        test_app = app_fixture(app.wsgifunc(*middleware))
        resp = test_app.post("/admin/getshelves", "some_query_string")

        assert resp.status is 200
        assert '["foo-shelf", "bar-shelf", "baz-shelf"]' == resp.body
Ejemplo n.º 3
0
    def test_parse_id_response(id):
        xml_string = get_file_as_string('tests/fixtures/book_by_id.xml')
        foo = parse_id_response(xml_string)

        assert foo == (
            453444, '1562828991', '9781562828998',
            "Disney's Art of Animation #1",
            'https://s.gr-assets.com/assets/nophoto/book/111x148-bcc042a9c91a29c1d680899eff700a03.png',
            '1992', '622', '4.29', 'Bob Thomas',
            'https://www.goodreads.com/book/show/453444.Disney_s_Art_of_Animation_1'
        )
Ejemplo n.º 4
0
    def test_get_by_id(self, monkeypatch):
        id = get_element('tests/fixtures/book_by_id.xml', 'book/id')

        monkeypatch.setattr('sorter.lib.book_utils.read_url', lambda *args: get_file_as_string('tests/fixtures/book_by_id.xml'))

        foo = get_by_id(1234, defaults)

        root = ElementTree.fromstring(foo)

        _id = root.find('book/id').text

        assert id == _id
Ejemplo n.º 5
0
    def test_get_shelf_list(self):
        xml_string = get_file_as_string('tests/fixtures/shelf_list.xml')

        shelf_list = get_shelf_list(xml_string)

        assert shelf_list == ['foo-shelf', 'bar-shelf', 'baz-shelf']
Ejemplo n.º 6
0
'''
Copy the contents of README.md to the Github Pages index.md
'''
import time
from tzlocal import get_localzone
from os.path import abspath
from tests.utils.get_element import get_file_as_string

top_copy = '''---
layout: default
---
%s



*Last Update: %s %s*
'''

readme = get_file_as_string('./README.md')


def write_file(my_file, content):
    fq_file = abspath(my_file)
    doc_file = open(fq_file, "w")
    doc_file.write(content)
    doc_file.close()


last_update = time.strftime("%c")
local_timezone = get_localzone()
write_file('./docs/index.md', top_copy % (readme, last_update, local_timezone))