def _assert_init(self, kwargs): """Run __init__ assertions. Args: kwargs (dict): keyword arguments for the Token initializer. Raises: AssertionError: Token attributes is not set as expected. """ token = Token(**kwargs) if 'bucket' in kwargs: assert token.bucket_id == kwargs['bucket'] else: assert token.bucket_id is None if 'expires' in kwargs: assert token.expires == datetime.fromtimestamp( strict_rfc3339.rfc3339_to_timestamp(kwargs['expires'])) else: assert token.expires is None if 'operation' in kwargs: assert token.operation == kwargs['operation'] else: assert token.operation is None if 'token' in kwargs: assert token.id == kwargs['token'] else: assert token.id is None
def test_init(self): """Test File.__init__().""" # https://storj.github.io/bridge/#!/buckets/get_buckets_id_files_file_id kwargs = dict(hash='ba084d3f143f2896809d3f1d7dffed472b39d8de', token='99cf1af00b552113a856f8ef44f58d22269389e8' '009d292bafd10af7cc30dcfa', operation='PULL', channel='ws://farmer.hostname:4000') fp = FilePointer(**kwargs) assert fp.hash == kwargs['hash'] assert fp.token == Token(token=kwargs['token']) assert fp.operation == kwargs['operation'] assert fp.channel == kwargs['channel']
def test_init(self): """Test Token.__init__().""" kwargs = dict( token=None, bucket='bucket_id', operation='operation', expires='2016-10-13T04:23:48.183Z', encryptionKey='key_id', ) token = Token(**kwargs) assert token.id == kwargs['token'] assert token.bucket == Bucket(id=kwargs['bucket']) assert token.operation == kwargs['operation'] assert token.expires == datetime.fromtimestamp( strict_rfc3339.rfc3339_to_timestamp(kwargs['expires'])) assert token.encryptionKey == kwargs['encryptionKey']