Пример #1
0
 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.api = API()
     self.client = DownstreamClient(self.server_url,
                                    self.token,
                                    self.address,
                                    self.size,
                                    self.msg,
                                    self.sig,
                                    self.api)
     self.test_contract = DownstreamContract(self.client,
                                             MockValues.get_chunk_response[
                                                 'file_hash'],
                                             MockValues.get_chunk_response[
                                                 'seed'],
                                             MockValues.get_chunk_response[
                                                 'size'],
                                             Heartbeat.challenge_type()
                                             .fromdict(
                                                 MockValues.
                                                 get_chunk_response['challe'
                                                                    'nge']),
                                             datetime.utcnow() +
                                             timedelta(
                                                 seconds=int(
                                                     MockValues.
                                                     get_chunk_response['du'
                                                                        'e']
                                                 )),
                                             Heartbeat.tag_type().fromdict(
                                                 MockValues
                                                 .get_chunk_response['ta'
                                                                     'g'],
                                             ),
                                             self.api)
     self.test_heartbeat = Heartbeat.fromdict(
         MockValues.connect_response['heartbeat'])
Пример #2
0
 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'])