Skip to content

Commit

Permalink
Updated test api command so it can be used from outside Freesound mac…
Browse files Browse the repository at this point in the history
…hines
  • Loading branch information
ffont committed Mar 24, 2014
1 parent cfbbed5 commit 191a421
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions sounds/management/commands/test_api.py
Expand Up @@ -24,7 +24,6 @@
import json
from django.core.management.base import BaseCommand
from django.contrib.sites.models import Site
from apiv2.models import ApiV2Client
from apiv2.examples import examples


Expand Down Expand Up @@ -56,17 +55,27 @@ def api_request(full_url, type='GET', post_data=None, auth='token', token=None):


class Command(BaseCommand):
help = "Test apiv2 with examples from apiv2/examples.py"
help = "Test apiv2 with examples from apiv2/examples.py. Usage: python manage.py test_api [custom_base_url] [token] [section]"

def handle(self, *args, **options):
if args:
section = str(args[0])
base_url = str(args[0])
if len(args) > 1:
token = str(args[1])
else:
token = False
if len(args) > 2:
section = str(args[2])
else:
section = False
else:
base_url = "http://%s/" % Site.objects.get_current().domain
section = False

client = ApiV2Client.objects.filter(user__username='frederic.font')[0]
token = client.client_secret
base_url = "http://%s/" % Site.objects.get_current().domain
if not token:
from apiv2.models import ApiV2Client
client = ApiV2Client.objects.filter(user__username='apitest')[0]
token = client.client_secret

ok = list()
failed = list()
Expand Down

0 comments on commit 191a421

Please sign in to comment.