Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.6.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Moser committed Jul 7, 2016
2 parents 00abb25 + e018552 commit 361ce4a
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@
* Fixed tests

## 1.6.6
* Updated readme
* Updated readme

## 1.6.7
* Implemented asynchronous input generation
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.6
1.6.7
23 changes: 20 additions & 3 deletions bitcodin/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import time


def create_input(input_obj):
def create_input(input_obj, async=False):
"""
Create an Input for bitcodin
:param input_obj: Input object to create
:return: Input
"""

res = RestClient.post(url=get_api_base()+'/input/create', headers=create_headers(), content=input_obj.to_json())
if async is False:
url = get_api_base()+'/input/create'
else:
url = get_api_base()+'/input/createasync'
res = RestClient.post(url=url, headers=create_headers(), content=input_obj.to_json())
input_obj = BitcodinObject(res, True)
return input_obj

Expand All @@ -33,6 +36,20 @@ def get_input(input_id=None):
return input_obj


def get_async_input_status(async_input_id=None):
"""
Get asynchronous created Input status
:param async_input_id: The id of the asynchronous created Input
:return: BitcodinObject
"""
url = get_api_base()+'/input/%d' % async_input_id + '/asyncstatus'
res = RestClient.get(url=url, headers=create_headers())

input_obj = BitcodinObject(res, True)

return input_obj


def list_inputs(page=None):
"""
Get a list of Inputs
Expand Down
46 changes: 46 additions & 0 deletions bitcodin/test/input/testcase_create_input_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from time import sleep

import unittest
from bitcodin import create_input, get_input, get_async_input_status
from bitcodin import delete_input
from bitcodin import S3Input
from bitcodin.test.settings import s3_input_config
from bitcodin.test.bitcodin_test_case import BitcodinTestCase


class CreateS3InputTestCase(BitcodinTestCase):
def setUp(self):
super(CreateS3InputTestCase, self).setUp()

def runTest(self):
input = S3Input(
access_key=s3_input_config.get('access_key'),
secret_key=s3_input_config.get('secret_key'),
host=s3_input_config.get('host'),
bucket=s3_input_config.get('bucket'),
region=s3_input_config.get('region'),
object_key=s3_input_config.get('object_key')
)

self.input = create_input(input, True)

async_input_status = get_async_input_status(self.input.input_id)
while async_input_status.status != 'CREATED':
async_input_status = get_async_input_status(async_input_status.input_id)
self.assertNotEqual(async_input_status.status, 'ERROR')
print(async_input_status.to_json())
sleep(5)

self.input = get_input(self.input.input_id)
self.assertEquals(self.input.host, input.host)
self.assertEquals(self.input.bucket, input.bucket)
self.assertEquals(self.input.region, input.region)
self.assertEquals(self.input.status, 'CREATED')

def tearDown(self):
delete_input(self.input.input_id)
super(CreateS3InputTestCase, self).tearDown()


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='bitcodin',
description='Python interface for bitcodin API',
version='1.6.6',
version='1.6.7',
author='David Moser, Dominic Miglar',
author_email='david.moser@bitmovin.net, dominic.miglar@bitmovin.net',
packages=['bitcodin'],
Expand Down

0 comments on commit 361ce4a

Please sign in to comment.