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


Python Heartbeat.fromdict方法代码示例

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


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

示例1: setUp

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def setUp(self):
     self.challenge = Heartbeat.challenge_type().\
         fromdict(
             MockValues
             .get_challenges_response['challenges'][0]['challenge'])
     self.heartbeat = Heartbeat.fromdict(
         MockValues.connect_response['heartbeat'])
     self.tag = Heartbeat.tag_type().fromdict(
         MockValues.get_chunks_response['chunks'][0]['tag'])
     self.expiration = datetime.utcnow(
     ) + timedelta(int(MockValues.get_chunks_response['chunks'][0]['due']))
     self.client = mock.MagicMock()
     self.manager = ThreadManager()
     self.test_hash = 'hash'
     self.test_size = 100
     self.test_seed = 'seed'
     self.contract = DownstreamContract(self.client,
                                        self.test_hash,
                                        self.test_seed,
                                        self.test_size,
                                        self.challenge,
                                        self.expiration,
                                        self.tag,
                                        self.manager,
                                        os.path.join('data', 'chunks'))
     self.contract.generate_data()
开发者ID:wiggzz,项目名称:downstream-farmer,代码行数:28,代码来源:test_unit.py

示例2: test_connect_sign

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def test_connect_sign(self):
     self.client.msg = 'test message'
     self.client.sig = 'HyzVUenXXo4pa+kgm1vS8PNJM83eIXFC5r0q86FGbqFcdla6rcw'
     '72/ciXiEPfjli3ENfwWuESHhv6K9esI0dl5I='
     self.client.address = '19qVgG8C6eXwKMMyvVegsi3xCsKyk3Z3jV'
     self.client.token = None
     with mock.patch('downstream_farmer.client.requests.post') as patch:
         patch.return_value.json.return_value = MockValues.connect_response
         self.client.connect()
     patch.assert_called_with('{0}/new/{1}'.format(self.server_url
                                                   .strip('/') + self
                                                   .api_path, self
                                                   .client.address),
                              data=json.dumps({
                                  "message": self.client.msg,
                                  "signature": self.client.sig
                              }),
                              headers={
         'Content-Type': 'application/json'
     },
         verify=None)
     self.assertEqual(
         self.client.token, MockValues.connect_response['token'])
     self.assertEqual(self.client.heartbeat,
                      Heartbeat.fromdict(MockValues
                                         .connect_response['heartbeat']))
开发者ID:wiggzz,项目名称:downstream-farmer,代码行数:28,代码来源:test_unit.py

示例3: test_connect_working

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def test_connect_working(self):
     with mock.patch('downstream_farmer.client.requests.get') as patch:
         inst = patch.return_value
         inst.json.return_value = MockValues.connect_response
         self.client.connect(self.server_url)
     self.assertEqual(self.client.token,MockValues.connect_response['token'])
     self.assertEqual(self.client.heartbeat,
                      Heartbeat.fromdict(MockValues.connect_response['heartbeat']))
开发者ID:nameone,项目名称:downstream-farmer,代码行数:10,代码来源:tests-unit.py

示例4: setUp

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def setUp(self):
     self.server_url = 'https://test.url/'
     self.address = base58.b58encode_check(b'\x00'+os.urandom(20))
     self.client = DownstreamClient(self.address)
     self.test_contract = Contract(MockValues.get_chunk_response['file_hash'],
                                   MockValues.get_chunk_response['seed'],
                                   MockValues.get_chunk_response['size'],
                                   Heartbeat.challenge_type().fromdict(
                                     MockValues.get_chunk_response['challenge']),
                                   datetime.strptime(
                                     MockValues.get_chunk_response['expiration'],
                                     '%Y-%m-%dT%H:%M:%S'),
                                   Heartbeat.tag_type().fromdict(
                                     MockValues.get_chunk_response['tag']))
     self.test_heartbeat = Heartbeat.fromdict(MockValues.connect_response['heartbeat'])
开发者ID:nameone,项目名称:downstream-farmer,代码行数:17,代码来源:tests-unit.py

示例5: setUp

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def setUp(self):
     self.server_url = 'https://test.url/'
     self.api_path = '/api/downstream/v1'
     self.size = 100
     self.address = base58.b58encode_check(b'\x00' + os.urandom(20))
     self.token = binascii.hexlify(os.urandom(16)).decode('ascii')
     self.msg = ''
     self.sig = ''
     self.thread_manager = ShellApplication()
     self.contract_thread = ManagedThread()
     self.chunk_dir = os.path.join('data', 'chunks')
     self.client = DownstreamClient(self.server_url,
                                    self.token,
                                    self.address,
                                    self.size,
                                    self.msg,
                                    self.sig,
                                    self.thread_manager,
                                    self.chunk_dir)
     self.client.session = mock.MagicMock()
     self.test_contract = \
         DownstreamContract(self.client,
                            MockValues.get_chunks_response[
                                'chunks'][0]['file_hash'],
                            MockValues.get_chunks_response[
                                'chunks'][0]['seed'],
                            MockValues.get_chunks_response[
                                'chunks'][0]['size'],
                            Heartbeat.challenge_type().fromdict(
                                MockValues
                                .get_chunks_response
                                ['chunks'][0]['challenge']),
                            datetime.utcnow() + timedelta(
                                seconds=int(
                                    MockValues
                                    .get_chunks_response
                                    ['chunks'][0]['due'])),
                            Heartbeat.tag_type().fromdict(
                                MockValues
                                .get_chunks_response
                                ['chunks'][0]['tag']),
                            self.thread_manager,
                            self.chunk_dir)
     self.test_heartbeat = Heartbeat.fromdict(
         MockValues.connect_response['heartbeat'])
开发者ID:NinjaDevelper,项目名称:downstream-farmer,代码行数:47,代码来源:test_unit.py

示例6: setUp

# 需要导入模块: from heartbeat import Heartbeat [as 别名]
# 或者: from heartbeat.Heartbeat import fromdict [as 别名]
 def setUp(self):
     self.challenge = Heartbeat.challenge_type().\
         fromdict(MockValues.get_challenge_response['challenge'])
     self.heartbeat = Heartbeat.fromdict(
         MockValues.connect_response['heartbeat'])
     self.tag = Heartbeat.tag_type().fromdict(
         MockValues.get_chunk_response['tag'])
     self.expiration = datetime.utcnow(
     ) + timedelta(int(MockValues.get_chunk_response['due']))
     self.client = mock.MagicMock()
     self.api = API()
     self.contract = DownstreamContract(self.client,
                                        'hash',
                                        'seed',
                                        100,
                                        self.challenge,
                                        self.expiration,
                                        self.tag,
                                        self.api)
开发者ID:mstg,项目名称:downstream-farmer,代码行数:21,代码来源:test_unit.py


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