示例#1
0
文件: tests.py 项目: Lefford/accounts
 def test_get_accounts(self):
     client = ImporterClient(self.base_url, self.url_param)
     response = client.get("api/v1account_lead/")
     self.assertEqual(200, response.status_code)
示例#2
0
文件: tests.py 项目: Lefford/accounts
 def test_resource_uri(self):
     client = ImporterClient(self.base_url, self.url_param)
     response = client.get("api/v1/account_lead/")
     response_01 = client.get(response.content["objects"][0]["resource_uri"])
     self.assertEqual(200, response_01.status_code)
示例#3
0
        if len(args) == 0:
            raise CommandError('Company and resource name required')
        
        company = None
        try:
            company = Company.objects.get(name=args[0])
        except Company.DoesNotExist, e:
            raise CommandError('{0} is a unknown company'.format(company))
        
        account = None
        if company:
            try:
                account = AccountConfiguration.objects.get(company=company)
            except AccountConfiguration.DoesNotExist, e:
                raise CommandError('{0} has no account configuration'.format(args[0]))
            
        if account:
            client = ImporterClient(account.base.url)
            response = None
            try:
                headers = dict()
                headers.update({'user name': account.user_name, 'api_key': account.api_key})
                response = client.get(args[1])
            except ValueError, e:
                raise CommandError('Error code {0} for fetching {1}'.format(e, args[1]))
            
            content = response.content if response else list()
            model = get_model(args[1])
            for resource in content:
                    resource# save resource in db