Tags: Virtual-X/tinycards-python-api
Tags
Add support for covers from URLs. Add support for PNG covers. (flosch… …a#58, resolves floscha#54) * Re-purpose Deck.cover for upload only. Add Deck.{cover_}image_url for read-only purposes This way, - `Deck.image_url` can strictly map to Tinycards API's `imageUrl`, - `Deck.cover_image_url` can strictly map to Tinycards API's `coverImageUrl`, - `Deck.cover` is only used for cover upload purposes, which is hopefully clearer, or at least, matches more closely Tinycards API's behaviour. * Add utilities to download images and identify their MIME types (+tests) * Add support for covers identified via URLs. Add support for PNG images (+tests)
Add support for JPEG deck covers (floscha#49, resolves floscha#47) * Add requests-toolbelt 0.9.1 as a dependency * Deck now sets the provided cover input argument as a field It previously was just ignored, and left unused. * deck_to_json now sets Deck#cover under imageFile It previously was ignored, but with a commented-out line which suggested this is where this should be added. * Add upload of jpeg deck cover (+integration test) * test_simple_multipart_form_parsing now UTF8-decodes and Unix-ises line endings of the actual form * rm tests/test_networking.py The current test really is just testing requests_toolbelt.multipart.encoder.MultipartEncoder, and has no real reason to remain as this MultipartEncoder is already heavily tested upstream. Note that prior to removal, tests were passing under some versions of Python, but not others, due to different orderings of the form values: - https://travis-ci.org/floscha/tinycards-python-api/jobs/506018179 - https://travis-ci.org/floscha/tinycards-python-api/builds/506018178 Besides, this logic is also covered by integration tests. * Actually test that the uploaded cover matches byte for byte This is a more robust test, albeit a bit more expensive, as the default cover could also eventually be hosted by cloudfront. * Add error details in the exception raised on failed deck update Otherwise, the reason of the failure is masked, which hinders debugging. * to_multipart_form now properly JSON-encodes cards Previously, the following would be added to the payload, resulting in errors server side, since invalid JSON: ``` Content-Disposition: form-data; name="cards"\r\n \r\n [{\'creationTimestamp\': 1552700740000, \'sides\': [{\'concepts\': [{\'fact\': {\'text\': \'front test 1\', \'type\': \'TEXT\'}}]}, {\'concepts\': [{\'fact\': {\'text\': \'back test 1\', \'type\': \'TEXT\'}}]}]}, {\'creationTimestamp\': 1552700740000, \'sides\': [{\'concepts\': [{\'fact\': {\'text\': \'front test 2\', \'type\': \'TEXT\'}}]}, {\'concepts\': [{\'fact\': {\'text\': \'back test 2\', \'type\': \'TEXT\'}}]}]}]\r\n ``` Indeed, when updating a deck's cover in the web UI, cards are encoded like this: ``` Content-Disposition: form-data; name="cards"\r\n \r\n [{"sides":[{"concepts":[{"fact":{"text":"Q1","type":"TEXT"}}]},{"concepts":[{"fact":{"text":"A1","type":"TEXT"}}]}]},{"sides":[{"concepts":[{"fact":{"type":"TEXT","text":"Q2"}}]},{"concepts":[{"fact":{"type":"TEXT","text":"A2"}}]}]}]\r\n ``` * Add support for update of decks' covers (+tests) * Document cover in Deck.__init__'s docstring
Upgrade **requests** version to remove vulnerability (https://nvd.nis… …t.gov/vuln/detail/CVE-2018-18074)
Merge pull request floscha#27 from njam/fix-error Make sure "error/" is added to package
Merge pull request floscha#26 from njam/version Release a new version