Esempio n. 1
0
 def testGetAnnotationsProtoNoB64decodable(self, mock_fn):
     data = {'logs': [{'datagram': {'data': 'data'}}]}
     mock_fn.return_value = json.dumps(data)
     step = logdog_util._GetAnnotationsProtoForPath('host', 'project',
                                                    'path',
                                                    self.http_client)
     self.assertIsNone(step)
Esempio n. 2
0
  def testGetAnnotationsProtoUseGet(self, mock_fn):
    step_proto = _CreateProtobufMessage(self.step_name, self.stdout_stream,
                                        self.step_metadata_stream)
    step_log = step_proto.SerializeToString()
    step_log_p1 = step_log[:len(step_log) / 2]
    step_log_p2 = step_log[len(step_log) / 2:]
    data1 = {
        'logs': [{
            'streamIndex': 1,
            'datagram': {
                'data': base64.b64encode(step_log_p2),
                'partial': {
                    'index': 1,
                    'size': 1234
                }
            }
        }]
    }
    data2 = {
        'logs': [{
            'streamIndex': 0,
            'datagram': {
                'data': base64.b64encode(step_log_p1),
                'partial': {
                    'size': 1234
                }
            }
        },
                 {
                     'streamIndex': 1,
                     'datagram': {
                         'data': base64.b64encode(step_log_p2),
                         'partial': {
                             'index': 1,
                             'size': 1234
                         }
                     }
                 }]
    }

    mock_fn.side_effect = [(200, json.dumps(data1)), (200, json.dumps(data2))]
    step = logdog_util._GetAnnotationsProtoForPath('host', 'project', 'path',
                                                   self.http_client)
    self.assertIsNotNone(step)
Esempio n. 3
0
 def testGetAnnotationsProtoNoLogs(self, _):
     step = logdog_util._GetAnnotationsProtoForPath('host', 'project',
                                                    'path',
                                                    self.http_client)
     self.assertIsNone(step)
Esempio n. 4
0
 def testGetAnnotationsProto(self, mock_fn):
     mock_fn.return_value = self._GenerateTailRes()
     step = logdog_util._GetAnnotationsProtoForPath('host', 'project',
                                                    'path',
                                                    self.http_client)
     self.assertIsNotNone(step)