|
| 1 | +if __name__ == '__main__' and __package__ is None: |
| 2 | + from os import sys, path |
| 3 | + sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) |
| 4 | +import blockscore |
| 5 | +import unittest |
| 6 | +import os, sys |
| 7 | + |
| 8 | +class TestBlockscoreCompanies(unittest.TestCase): |
| 9 | + |
| 10 | + def setUp(self): |
| 11 | + try: |
| 12 | + self.client = blockscore.Client({'api_key': os.environ['BLOCKSCORE_API']}) |
| 13 | + except KeyError: |
| 14 | + sys.stderr.write("To run tests, you must have a BLOCKSCORE_API environment variable with a test api key\n") |
| 15 | + sys.exit(2) |
| 16 | + |
| 17 | + self.test_company = { |
| 18 | + "entity_name": "BlockScore", |
| 19 | + "tax_id": "123410000", |
| 20 | + "incorp_date": "1980-08-25", |
| 21 | + "incorp_state": "DE", |
| 22 | + "incorp_country_code": "US", |
| 23 | + "incorp_type": "corporation", |
| 24 | + "dbas": "BitRemite", |
| 25 | + "registration_number": "123123123", |
| 26 | + |
| 27 | + "url": "https://blockscore.com", |
| 28 | + "phone_number": "6505555555", |
| 29 | + "ip_address": "67.160.8.182", |
| 30 | + "address": { |
| 31 | + "street1": "1 Infinite Loop", |
| 32 | + "street2": None, |
| 33 | + "city": "Cupertino", |
| 34 | + "state": "CA", |
| 35 | + "postal_code": "95014", |
| 36 | + "country_code": "US", |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + def test_list_companies(self): |
| 41 | + response = self.client.companies.all() |
| 42 | + self.assertEqual(200, response.code) |
| 43 | + |
| 44 | + response = self.client.companies.all(count=2) |
| 45 | + self.assertEqual(200, response.code) |
| 46 | + |
| 47 | + response = self.client.companies.all(count=2, offset=2) |
| 48 | + self.assertEqual(200, response.code) |
| 49 | + |
| 50 | + def test_retrieve_company(self): |
| 51 | + response = self.client.companies.create(self.test_company) |
| 52 | + body = response.body |
| 53 | + |
| 54 | + response = self.client.companies.retrieve(body['id']) |
| 55 | + body = response.body |
| 56 | + |
| 57 | + self.assertEqual(200, response.code) |
| 58 | + self.assertEqual(self.test_company['entity_name'], body['entity_name']) |
| 59 | + |
| 60 | + def test_create_company(self): |
| 61 | + response = self.client.companies.create(self.test_company) |
| 62 | + self.assertEqual(201, response.code) |
| 63 | + |
| 64 | +if __name__ == '__main__': |
| 65 | + unittest.main() |
| 66 | + |
0 commit comments