def test_make_headers_with_empty_or_none_timestamp(self):
        bad_timestamps = ['', None]

        for bad_timestamp in bad_timestamps:
            with self.assertRaises(ValueError) as cm:
                make_headers(self.dummy_api_key, self.dummy_token, self.dummy_authorization, self.dummy_nonce,
                             bad_timestamp)

            raised_message = str(cm.exception)
            expected_message = 'Timestamp value cannot be empty or None'
            self.assertEqual(raised_message, expected_message)
Exemple #2
0
    def test_make_headers_with_empty_or_none_timestamp(self):
        bad_timestamps = ['', None]

        for bad_timestamp in bad_timestamps:
            with self.assertRaises(ValueError) as cm:
                make_headers(self.dummy_api_key, self.dummy_token,
                             self.dummy_authorization, self.dummy_nonce,
                             bad_timestamp)

            raised_message = str(cm.exception)
            expected_message = 'Timestamp value cannot be empty or None'
            self.assertEqual(raised_message, expected_message)
Exemple #3
0
 def run_transaction(self):
     authorization, nonce, timestamp = generate_hmac(
         self.api_key, self.api_secret, self.token, self.payload)
     headers = make_headers(self.api_key, self.token, authorization, nonce,
                            timestamp)
     transaction_results = requests.post(url=self.url,
                                         data=self.payload,
                                         headers=headers)
     self.__set_transaction_response(transaction_results)
    def test_make_headers_with_good_data(self):
        expected_headers = {
            'apikey': self.dummy_api_key,
            'token': self.dummy_token,
            'Content-type': 'application/json',
            'Authorization': self.dummy_authorization,
            'nonce': self.dummy_nonce,
            'timestamp': self.dummy_timestamp
        }

        headers = make_headers(self.dummy_api_key, self.dummy_token, self.dummy_authorization, self.dummy_nonce,
                               self.dummy_timestamp)
        self.assertEqual(headers, expected_headers)
Exemple #5
0
    def test_make_headers_with_good_data(self):
        expected_headers = {
            'apikey': self.dummy_api_key,
            'token': self.dummy_token,
            'Content-type': 'application/json',
            'Authorization': self.dummy_authorization,
            'nonce': self.dummy_nonce,
            'timestamp': self.dummy_timestamp
        }

        headers = make_headers(self.dummy_api_key, self.dummy_token,
                               self.dummy_authorization, self.dummy_nonce,
                               self.dummy_timestamp)
        self.assertEqual(headers, expected_headers)
    def test_make_headers_if_dict_has_type_string_values(self):
        expected_headers = {
            'apikey': str(self.dummy_api_key),
            'token': str(self.dummy_token),
            'Content-type': 'application/json',
            'Authorization': str(self.dummy_authorization),
            'nonce': str(self.dummy_nonce),
            'timestamp': str(self.dummy_timestamp)
        }

        headers = make_headers(self.dummy_api_key, self.dummy_token, self.dummy_authorization, self.dummy_nonce,
                               self.dummy_timestamp)
        self.assertEqual(headers, expected_headers)
        self.assertIsInstance(headers['apikey'], str)
        self.assertIsInstance(headers['token'], str)
        self.assertIsInstance(headers['Content-type'], str)
        self.assertIsInstance(headers['Authorization'], str)
        self.assertIsInstance(headers['nonce'], str)
        self.assertIsInstance(headers['timestamp'], str)
Exemple #7
0
    def test_make_headers_if_dict_has_type_string_values(self):
        expected_headers = {
            'apikey': str(self.dummy_api_key),
            'token': str(self.dummy_token),
            'Content-type': 'application/json',
            'Authorization': str(self.dummy_authorization),
            'nonce': str(self.dummy_nonce),
            'timestamp': str(self.dummy_timestamp)
        }

        headers = make_headers(self.dummy_api_key, self.dummy_token,
                               self.dummy_authorization, self.dummy_nonce,
                               self.dummy_timestamp)
        self.assertEqual(headers, expected_headers)
        self.assertIsInstance(headers['apikey'], str)
        self.assertIsInstance(headers['token'], str)
        self.assertIsInstance(headers['Content-type'], str)
        self.assertIsInstance(headers['Authorization'], str)
        self.assertIsInstance(headers['nonce'], str)
        self.assertIsInstance(headers['timestamp'], str)
Exemple #8
0
 def run_transaction(self):
     authorization, nonce, timestamp = generate_hmac(self.api_key, self.api_secret, self.token, self.payload)
     headers = make_headers(self.api_key, self.token, authorization, nonce, timestamp)
     transaction_results = requests.post(url=self.url, data=self.payload, headers=headers)
     self.__set_transaction_response(transaction_results)