Merge pull request #48 from NandaScott/develop

Develop
This commit is contained in:
Nanda Scott 2020-06-09 10:04:54 -04:00 committed by GitHub
commit b45e4d13f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 195 additions and 14 deletions

26
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Python Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest

View File

@ -1,5 +1,13 @@
# Changelog
## 1.8.0
Changes
- CI tests have now been added
- Bulk data uri method has been updated, with a deprecation warning for the previous method.
- `preview()` method has been added to all card methods.
- Tests have been updated to reflect new changes.
## 1.7.1
New stuff
- Added image uri compatability for adventure cards

View File

@ -123,14 +123,7 @@ Returns the type of object the specified index is
### `bulk_permalink_uri()`
```
The URL that hosts the bulk file
Args:
num (int): The index of the object in the `data` key
Returns:
string: A URI to download the compressed data
None
```
---
### `bulk_type()`
@ -157,6 +150,19 @@ The time the item was last updated
Returns:
string: Timestamp
```
---
### `bulk_uri()`
```
The URL that hosts the bulk file
Args:
num (int): The index of the object in the `data` key
Returns:
string: A URI to download the compressed data
```
---
### `data()`

View File

@ -432,6 +432,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -429,6 +429,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -432,6 +432,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -432,6 +432,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -432,6 +432,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -434,6 +434,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -430,6 +430,22 @@ The power of the creature, if applicable
Returns:
string
```
---
### `preview()`
```
Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
```
---
### `prices()`

View File

@ -5,6 +5,7 @@ import asyncio
import aiohttp
import urllib.parse
from threading import Thread
import warnings
class BulkData(FoundationObject):
"""
@ -164,6 +165,10 @@ class BulkData(FoundationObject):
return self.scryfallJson['data'][num]['compressed_size']
def bulk_permalink_uri(self, num):
warnings.warn("This method has been renamed to bulk_uri as per https://scryfall.com/blog/updates-to-bulk-data-and-cards-deprecation-notice-217", DeprecationWarning)
return self.bulk_uri(num)
def bulk_uri(self, num):
"""The URL that hosts the bulk file
Args:
@ -172,9 +177,9 @@ class BulkData(FoundationObject):
Returns:
string: A URI to download the compressed data
"""
super(BulkData, self)._checkForTupleKey('data', num, 'permalink_uri')
super(BulkData, self)._checkForTupleKey('data', num, 'uri')
return self.scryfallJson['data'][num]['permalink_uri']
return self.scryfallJson['data'][num]['uri']
def bulk_content_type(self, num):
"""The MIME type of the file

View File

@ -729,3 +729,22 @@ class CardsObject(FoundationObject):
super(CardsObject, self)._checkForKey('released_at')
return self.scryfallJson['released_at']
def preview(self, key=None):
"""Preview information for this card, if any.
You may pass the name of a valid key to return the value of that key.
Such as a source_uri.
Args:
key (string): A key for specific information about the preview.
Returns:
dict: If provided no key, the entire dict is returned.
string: If provided a key, the value of that key is returned.
"""
super(CardsObject, self)._checkForKey('preview')
if key in self.scryfallJson['preview']:
return self.scryfallJson['preview'][key]
return self.scryfallJson['preview']

View File

@ -3,7 +3,7 @@ from setuptools import setup
setup(
name='scrython',
packages=['scrython', 'scrython.cards', 'scrython.rulings', 'scrython.catalog', 'scrython.sets', 'scrython.symbology', 'scrython.bulk_data'],
version='1.7.1',
version='1.8.0',
description='A wrapper for using the Scryfall API.',
long_description='https://github.com/NandaScott/Scrython/blob/master/README.md',
url='https://github.com/NandaScott/Scrython',

0
unittests/__init__.py Normal file
View File

View File

@ -41,8 +41,8 @@ class TestBulk(unittest.TestCase):
self.assertIsInstance(bulk.bulk_compressed_size(0), int)
self.assertIsInstance(bulk.bulk_compressed_size(0, True), str)
def test_bulk_permalink_uri(self):
self.assertIsInstance(bulk.bulk_permalink_uri(0), str)
def test_bulk_uri(self):
self.assertIsInstance(bulk.bulk_uri(0), str)
def test_bulk_content_type(self):
self.assertIsInstance(bulk.bulk_content_type(0), str)

View File

@ -17,6 +17,7 @@ transform = Id(id='aae6fb12-b252-453b-bca7-1ea2a0d6c8dc'); time.sleep(0.1)
vanguard = Id(id='87c1234b-3834-4bba-bef2-05707bb1e8e2'); time.sleep(0.1)
alt_lang_card = Collector(code='ths', collector_number='75', lang='ja'); time.sleep(0.1)
planeswalker = Id(id='4c565076-5db2-47ea-8ee0-4a4fd7bb353d'); time.sleep(0.1)
preview_check = Id(id='fb6b12e7-bb93-4eb6-bad1-b256a6ccff4e'); time.sleep(0.1)
autocomplete = Autocomplete(q='Thal'); time.sleep(0.1)
@ -207,6 +208,10 @@ class TestCardObjects(unittest.TestCase):
def test_oversized(self):
self.assertIsInstance(non_online_card.oversized(), bool)
def test_preview(self):
self.assertIsInstance(preview_check.preview(), dict)
self.assertIsInstance(preview_check.preview('source'), str)
class TestAutocomplete(unittest.TestCase):
def test_object(self):