def test_jsondumps(self): from pyimeji.util import jsonload, jsondumps object_test = jsonload( os.path.join(os.path.dirname(__file__), 'test.json')) self.assertIsNotNone(jsondumps(object_test)) self.assertEqual( jsondumps(object_test), open(os.path.join(os.path.dirname(__file__), 'test.json'), mode='rb').read())
for name in ['item', 'collection', 'album', 'profile'] } class Response(object): def __init__(self, key, status, content): self.key = key self.status = status self.content = content RESPONSES = {} for path, method, status, content in [ ('items', 'get', 200, jsondumps([{ "id": "Wo1JI_oZNyrfxV_t" }])), ('items', 'post', 201, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'delete', 204, {}), ('items/Wo1JI_oZNyrfxV_t', 'get', 200, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'put', 200, RESOURCES['item']), ('collections', 'get', 200, jsondumps([{ "id": "FKMxUpYdV9N2J4XG" }])), ('collections', 'post', 201, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG/release', 'put', 200, {}), ('collections/FKMxUpYdV9N2J4XG', 'delete', 204, {}), ('collections/FKMxUpYdV9N2J4XG', 'get', 200, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG/items', 'get', 200, jsondumps([RESOURCES['item']])), ('profiles/dhV6XK39_UPrItK5', 'get', 200, RESOURCES['profile']),
RESOURCES = { name: jsonload(pkg_path('tests', 'resources', '%s.json' % name)) for name in ['item', 'collection', 'album', 'profile']} class Response(object): def __init__(self, key, status, content): self.key = key self.status = status self.content = content RESPONSES = {} for path, method, status, content in [ ('items', 'get', 200, jsondumps([{"id": "Wo1JI_oZNyrfxV_t"}])), ('items', 'post', 201, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'delete', 204, {}), ('items/Wo1JI_oZNyrfxV_t', 'get', 200, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'put', 200, RESOURCES['item']), ('collections', 'get', 200, jsondumps([{"id": "FKMxUpYdV9N2J4XG"}])), ('collections', 'post', 201, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG/release', 'put', 200, {}), ('collections/FKMxUpYdV9N2J4XG', 'delete', 204, {}), ('collections/FKMxUpYdV9N2J4XG', 'get', 200, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG/items', 'get', 200, jsondumps([RESOURCES['item']])), ('profiles/dhV6XK39_UPrItK5', 'get', 200, RESOURCES['profile']), ('albums', 'get', 200, jsondumps([{"id": "MAlOuZ4Y9iDR_"}])),
def test_jsondumps(self): from pyimeji.util import jsonload, jsondumps object_test = jsonload(os.path.join(os.path.dirname(__file__), 'test.json')) self.assertIsNotNone(jsondumps(object_test)) self.assertEqual(jsondumps(object_test), open(os.path.join(os.path.dirname(__file__), 'test.json'), mode='rb').read())
] } class Response(object): def __init__(self, key, status, content): self.key = key self.status = status self.content = content RESPONSES = {} for path, method, status, content in [ ('items', 'get', 200, jsondumps([{ "id": "Wo1JI_oZNyrfxV_t" }])), ('items', 'post', 201, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'delete', 204, {}), ('items/Wo1JI_oZNyrfxV_t', 'get', 200, RESOURCES['item']), ('items/Wo1JI_oZNyrfxV_t', 'put', 200, RESOURCES['item']), ('collections', 'get', 200, RESOURCES['collections']), ('collections', 'post', 201, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG', 'put', 200, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG/release', 'put', 200, {}), ('collections/FKMxUpYdV9N2J4XG', 'delete', 204, {}), ('collections/FKMxUpYdV9N2J4XG', 'get', 200, RESOURCES['collection']), ('collections/FKMxUpYdV9N2J4XG?q=Test&offset=0&size=1', 'get', 200, RESOURCES['collections']), ('collections/FKMxUpYdV9N2J4XG/items', 'get', 200, jsondumps([RESOURCES['item']])), ('collections/FKMxUpYdV9N2J4XG/items/template', 'get', 200,