Esempio n. 1
0
 def __init__(self,
              contract_id,
              token,
              api_base='https://api.contiamo.com'):
     self.api_base = api_base
     self.token = token
     self.url_template = contract_url_template_from_identifier(
         contract_id, api_base)
     self.client = HTTPClient()
Esempio n. 2
0
def mock_erroneous_upload(response_body, status):
    contract_id = 'contract:48590121:666570779:test'
    contract_url = contract_url_template_from_identifier(
        contract_id, api_base).format(action='upload/process')
    responses.add(responses.POST,
                  contract_url,
                  body=response_body,
                  status=status,
                  content_type='application/json')
    data_client = DataClient(contract_id, 'contract_token', api_base=api_base)
    data_client.upload(filename=utils.file_test_data('mock_data.csv'))
Esempio n. 3
0
 def test_invalid_contract_id(self):
     with self.assertRaises(InvalidRequestError):
         contract_url_template_from_identifier(
             'contract:48590121:666570779:test:randomcontracttoken',
             api_base=self.api_base)
Esempio n. 4
0
 def test_contract_url_template(self):
     url_template = contract_url_template_from_identifier(
         'contract:48590121:666570779:test', api_base=self.api_base)
     self.assertEqual(
         url_template, self.api_base +
         '/48590121/apps/666570779/data_contracts/contracts/test/{action}')