当前位置: 首页>>代码示例>>Python>>正文


Python Mocks.make_txns方法代码示例

本文整理汇总了Python中tests.unit.components.Mocks.make_txns方法的典型用法代码示例。如果您正苦于以下问题:Python Mocks.make_txns方法的具体用法?Python Mocks.make_txns怎么用?Python Mocks.make_txns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.unit.components.Mocks的用法示例。


在下文中一共展示了Mocks.make_txns方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_txn_list_paginated_without_count

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_paginated_without_count(self):
        """Verifies GET /transactions paginated without count works properly.

        It will receive a Protobuf response with:
            - a head id of 'd'
            - a paging response with a start of 2, and 4 total resources
            - two transactions with the ids 'b' and 'a'

        It should send a Protobuf request with:
            - paging controls with a start_index of 2

        It should send back a JSON response with:
            - a response status of 200
            - a head property of 'd'
            - a link property that ends in '/transactions?head=d&min=2'
            - paging that matches the response, with a previous link
            - a data property that is a list of 2 dicts
            - those dicts are full transactions with ids 'd' and 'c'
        """
        paging = Mocks.make_paging_response(2, 4)
        self.connection.preset_response(
            head_id='d',
            paging=paging,
            transactions=Mocks.make_txns('b', 'a'))

        response = await self.get_assert_200('/transactions?min=2')
        controls = Mocks.make_paging_controls(None, start_index=2)
        self.connection.assert_valid_request_sent(paging=controls)

        self.assert_has_valid_head(response, 'd')
        self.assert_has_valid_link(response, '/transactions?head=d&min=2')
        self.assert_has_valid_paging(response, paging,
                                     previous_link='/transactions?head=d&min=0&count=2')
        self.assert_has_valid_data_list(response, 2)
        self.assert_txns_well_formed(response['data'], 'b', 'a')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:37,代码来源:test_txn_requests.py

示例2: test_txn_list_paginated_by_max_index

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_paginated_by_max_index(self):
        """Verifies GET /transactions paginated by a max index works properly.

        It will receive a Protobuf response with:
            - a head id of 'd'
            - a paging response with a start of 0, and 4 total resources
            - three transactions with the ids 'd', 'c' and 'b'

        It should send a Protobuf request with:
            - paging controls with a count of 3, and an start_index of 0

        It should send back a JSON response with:
            - a response status of 200
            - a head property of 'd'
            - a link property that ends in '/transactions?head=d&min=3&count=7'
            - paging that matches the response, with a next link
            - a data property that is a list of 2 dicts
            - those dicts are full transactions with ids 'd', 'c', and 'b'
        """
        paging = Mocks.make_paging_response(0, 4)
        self.connection.preset_response(
            head_id='d',
            paging=paging,
            transactions=Mocks.make_txns('d', 'c', 'b'))

        response = await self.get_assert_200('/transactions?max=2&count=7')
        controls = Mocks.make_paging_controls(3, start_index=0)
        self.connection.assert_valid_request_sent(paging=controls)

        self.assert_has_valid_head(response, 'd')
        self.assert_has_valid_link(response, '/transactions?head=d&max=2&count=7')
        self.assert_has_valid_paging(response, paging,
                                     '/transactions?head=d&min=3&count=7')
        self.assert_has_valid_data_list(response, 3)
        self.assert_txns_well_formed(response['data'], 'd', 'c', 'b')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:37,代码来源:test_txn_requests.py

示例3: test_txn_list

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list(self):
        """Verifies a GET /transactions without parameters works properly.

        It will receive a Protobuf response with:
            - a head id of '2'
            - a paging response with a start of 0, and 3 total resources
            - three transactions with ids of '2', '1', and '0'

        It should send a Protobuf request with:
            - empty paging controls

        It should send back a JSON response with:
            - a response status of 200
            - a head property of '2'
            - a link property that ends in '/transactions?head=2'
            - a paging property that matches the paging response
            - a data property that is a list of 3 dicts
            - those dicts are full transactions with ids '2', '1', and '0'
        """
        paging = Mocks.make_paging_response(0, 3)
        self.connection.preset_response(
            head_id='2',
            paging=paging,
            transactions=Mocks.make_txns('2', '1', '0'))

        response = await self.get_assert_200('/transactions')
        controls = Mocks.make_paging_controls()
        self.connection.assert_valid_request_sent(paging=controls)

        self.assert_has_valid_head(response, '2')
        self.assert_has_valid_link(response, '/transactions?head=2')
        self.assert_has_valid_paging(response, paging)
        self.assert_has_valid_data_list(response, 3)
        self.assert_txns_well_formed(response['data'], '2', '1', '0')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:36,代码来源:test_txn_requests.py

示例4: test_txn_list_with_ids

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_with_ids(self):
        """Verifies GET /transactions with an id filter works properly.

        It will receive a Protobuf response with:
            - a head id of '2'
            - a paging response with a start of 0, and 2 total resources
            - two transactions with ids of '0' and '2'

        It should send a Protobuf request with:
            - a transaction_ids property of ['0', '2']
            - empty paging controls

        It should send back a JSON response with:
            - a response status of 200
            - a head property of '2', the latest
            - a link property that ends in '/transactions?head=2&id=0,2'
            - a paging property that matches the paging response
            - a data property that is a list of 2 dicts
            - those dicts are full transactions with ids '0' and '2'
        """
        paging = Mocks.make_paging_response(0, 2)
        transactions = Mocks.make_txns('0', '2')
        self.connection.preset_response(head_id='2', paging=paging, transactions=transactions)

        response = await self.get_assert_200('/transactions?id=0,2')
        controls = Mocks.make_paging_controls()
        self.connection.assert_valid_request_sent(transaction_ids=['0', '2'], paging=controls)

        self.assert_has_valid_head(response, '2')
        self.assert_has_valid_link(response, '/transactions?head=2&id=0,2')
        self.assert_has_valid_paging(response, paging)
        self.assert_has_valid_data_list(response, 2)
        self.assert_txns_well_formed(response['data'], '0', '2')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:35,代码来源:test_txn_requests.py

示例5: test_txn_list_sorted_by_many_keys

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_sorted_by_many_keys(self):
        """Verifies a GET /transactions can send proper sort parameters.

        It will receive a Protobuf response with:
            - a head id of '2'
            - a paging response with a start of 0, and 3 total resources
            - three transactions with ids '2', '1', and '0'

        It should send a Protobuf request with:
            - empty paging controls
            - multiple sort controls with:
                * a key of 'header_signature' that is reversed
                * a key of 'payload' that is sorted by length

        It should send back a JSON response with:
            - a status of 200
            - a head property of '2'
            - link with '/transactions?head=2&sort=-header_signature,payload.length'
            - a paging property that matches the paging response
            - a data property that is a list of 3 dicts
            - and those dicts are full transactions with ids '2', '1', and '0'
        """
        paging = Mocks.make_paging_response(0, 3)
        transactions = Mocks.make_txns('2', '1', '0')
        self.connection.preset_response(head_id='2', paging=paging, transactions=transactions)

        response = await self.get_assert_200(
            '/transactions?sort=-header_signature,payload.length')
        page_controls = Mocks.make_paging_controls()
        sorting = (Mocks.make_sort_controls('header_signature', reverse=True) +
                   Mocks.make_sort_controls('payload', compare_length=True))
        self.connection.assert_valid_request_sent(
            paging=page_controls,
            sorting=sorting)

        self.assert_has_valid_head(response, '2')
        self.assert_has_valid_link(response,
            '/transactions?head=2&sort=-header_signature,payload.length')
        self.assert_has_valid_paging(response, paging)
        self.assert_has_valid_data_list(response, 3)
        self.assert_txns_well_formed(response['data'], '2', '1', '0')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:43,代码来源:test_txn_requests.py

示例6: test_txn_list_paginated_by_max_id

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_paginated_by_max_id(self):
        """Verifies GET /transactions paginated by a max id works properly.

        It will receive a Protobuf response with:
            - a head id of 'd'
            - a paging response with:
                * a start_index of 1
                * a total_resources of 4
                * a previous_id of 'd'
                * a next_id of 'a'
            - two transactions with the ids 'c' and 'b'

        It should send a Protobuf request with:
            - paging controls with a count of 2, and an end_id of 'b'

        It should send back a JSON response with:
            - a response status of 200
            - a head property of 'd'
            - a link property that ends in '/transactions?head=d&max=b&count=2'
            - paging that matches the response, with next and previous links
            - a data property that is a list of 2 dicts
            - those dicts are full transactions with ids 'c' and 'b'
        """
        paging = Mocks.make_paging_response(1, 4, previous_id='d', next_id='a')
        self.connection.preset_response(
            head_id='d',
            paging=paging,
            transactions=Mocks.make_txns('c', 'b'))

        response = await self.get_assert_200('/transactions?max=b&count=2')
        controls = Mocks.make_paging_controls(2, end_id='b')
        self.connection.assert_valid_request_sent(paging=controls)

        self.assert_has_valid_head(response, 'd')
        self.assert_has_valid_link(response, '/transactions?head=d&max=b&count=2')
        self.assert_has_valid_paging(response, paging,
                                     '/transactions?head=d&min=a&count=2',
                                     '/transactions?head=d&max=d&count=2')
        self.assert_has_valid_data_list(response, 2)
        self.assert_txns_well_formed(response['data'], 'c', 'b')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:42,代码来源:test_txn_requests.py

示例7: test_txn_list_with_head_and_ids

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_with_head_and_ids(self):
        """Verifies GET /transactions with head and id parameters work properly.

        It should send a Protobuf request with:
            - a head_id property of '1'
            - a paging response with a start of 0, and 1 total resource
            - a transaction_ids property of ['0']

        It will receive a Protobuf response with:
            - a head id of '1'
            - one transaction with an id of '0'
            - empty paging controls

        It should send back a JSON response with:
            - a response status of 200
            - a head property of '1'
            - a link property that ends in '/transactions?head=1&id=0'
            - a paging property that matches the paging response
            - a data property that is a list of 1 dict
            - that dict is a full transaction with an id of '0'
        """
        paging = Mocks.make_paging_response(0, 1)
        self.connection.preset_response(
            head_id='1',
            paging=paging,
            transactions=Mocks.make_txns('0'))

        response = await self.get_assert_200('/transactions?id=0&head=1')
        controls = Mocks.make_paging_controls()
        self.connection.assert_valid_request_sent(
            head_id='1',
            transaction_ids=['0'],
            paging=controls)

        self.assert_has_valid_head(response, '1')
        self.assert_has_valid_link(response, '/transactions?head=1&id=0')
        self.assert_has_valid_paging(response, paging)
        self.assert_has_valid_data_list(response, 1)
        self.assert_txns_well_formed(response['data'], '0')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:41,代码来源:test_txn_requests.py

示例8: test_txn_list_sorted_with_nested_keys

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_sorted_with_nested_keys(self):
        """Verifies GET /transactions can send proper sort controls with nested keys.

        It will receive a Protobuf response with:
            - a head id of '2'
            - a paging response with a start of 0, and 3 total resources
            - three transactions with ids '0', '1', and '2'

        It should send a Protobuf request with:
            - empty paging controls
            - sort controls with keys of 'header' and 'signer_pubkey'

        It should send back a JSON response with:
            - a status of 200
            - a head property of '2'
            - a link ending in '/transactions?head=2&sort=header.signer_pubkey'
            - a paging property that matches the paging response
            - a data property that is a list of 3 dicts
            - and those dicts are full transactions with ids '0', '1', and '2'
        """
        paging = Mocks.make_paging_response(0, 3)
        transactions = Mocks.make_txns('0', '1', '2')
        self.connection.preset_response(head_id='2', paging=paging, transactions=transactions)

        response = await self.get_assert_200(
            '/transactions?sort=header.signer_pubkey')
        page_controls = Mocks.make_paging_controls()
        sorting = Mocks.make_sort_controls('header', 'signer_pubkey')
        self.connection.assert_valid_request_sent(
            paging=page_controls,
            sorting=sorting)

        self.assert_has_valid_head(response, '2')
        self.assert_has_valid_link(response,
            '/transactions?head=2&sort=header.signer_pubkey')
        self.assert_has_valid_paging(response, paging)
        self.assert_has_valid_data_list(response, 3)
        self.assert_txns_well_formed(response['data'], '0', '1', '2')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:40,代码来源:test_txn_requests.py

示例9: test_txn_get

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_get(self):
        """Verifies a GET /transactions/{transaction_id} works properly.

        It should send a Protobuf request with:
            - a transaction_id property of '1'

        It will receive a Protobuf response with:
            - a transaction with an id of '1'

        It should send back a JSON response with:
            - a response status of 200
            - no head property
            - a link property that ends in '/transactions/1'
            - a data property that is a full batch with an id of '1'
        """
        self.connection.preset_response(transaction=Mocks.make_txns('1')[0])

        response = await self.get_assert_200('/transactions/1')
        self.connection.assert_valid_request_sent(transaction_id='1')

        self.assertNotIn('head', response)
        self.assert_has_valid_link(response, '/transactions/1')
        self.assertIn('data', response)
        self.assert_txns_well_formed(response['data'], '1')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:26,代码来源:test_txn_requests.py

示例10: test_txn_list_paginated

# 需要导入模块: from tests.unit.components import Mocks [as 别名]
# 或者: from tests.unit.components.Mocks import make_txns [as 别名]
    async def test_txn_list_paginated(self):
        """Verifies GET /transactions paginated by min id works properly.

        It will receive a Protobuf response with:
            - a head id of 'd'
            - a paging response with a start of 1, and 4 total resources
            - one transaction with the id 'c'

        It should send a Protobuf request with:
            - paging controls with a count of 1, and a start_index of 1

        It should send back a JSON response with:
            - a response status of 200
            - a head property of 'd'
            - a link property that ends in '/transactions?head=d&min=1&count=1'
            - paging that matches the response, with next and previous links
            - a data property that is a list of 1 dict
            - that dict is a full transaction with the id 'c'
        """
        paging = Mocks.make_paging_response(1, 4)
        self.connection.preset_response(
            head_id='d',
            paging=paging,
            transactions=Mocks.make_txns('c'))

        response = await self.get_assert_200('/transactions?min=1&count=1')
        controls = Mocks.make_paging_controls(1, start_index=1)
        self.connection.assert_valid_request_sent(paging=controls)

        self.assert_has_valid_head(response, 'd')
        self.assert_has_valid_link(response, '/transactions?head=d&min=1&count=1')
        self.assert_has_valid_paging(response, paging,
                                     '/transactions?head=d&min=2&count=1',
                                     '/transactions?head=d&min=0&count=1')
        self.assert_has_valid_data_list(response, 1)
        self.assert_txns_well_formed(response['data'], 'c')
开发者ID:feihujiang,项目名称:sawtooth-core,代码行数:38,代码来源:test_txn_requests.py


注:本文中的tests.unit.components.Mocks.make_txns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。