# Path: accounts/models.py
# class Account(AbstractUser):
#     """
#     This is our custom 'User' model.
#     """
# 
#     is_developer = models.BooleanField(default=False, blank=False)
#     accepted_tos = models.BooleanField(default=False, blank=False)
#     #  Add more custom fields here like avatar...
# 
#     def send_activation_email(self):
#         tvars = {
#             'user': self,
#             'username': self.username,
#             'hash': create_hash(self.id)
#         }
#         send_mail(self.email, subject='Activate your Audio Commons user account',
#                   template='emails/account_activation.txt', context=tvars)
# 
#     class Meta:
#         verbose_name = _('account')
#         verbose_name_plural = _('accounts')
# 
# Path: services/mgmt.py
# def get_service_by_name(service_name):
#     for service in available_services:
#         if service.name == service_name:
#             return service
#     raise ACServiceDoesNotExist('Service with name {0} does not exist'.format(service_name))


from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from accounts.models import Account
from services.acservice.constants import *
from ac_mediator.exceptions import *
from services.mgmt import get_service_by_name
import configparser
import os
import logging
import json
    return {
        'status': 'IN',
        'response': 'Invalid or not supported component'
    }


class Command(BaseCommand):
    help = 'Test an implementation of a 3rd party service integration with the Audio Commons Mediator.'

    def add_arguments(self, parser):
        parser.add_argument('service_name', type=str, help='Name or id of the service to test')
        parser.add_argument('--out_filename', dest='out_filename', type=str,
                            help='Filename where to save the output of the test. '
                                 'Defaults to "out_test_<SERVICE_NAME>.html"')
        parser.add_argument('--test_config_filename', dest='test_config_filename', type=str,
                            help='Filename where to configuration parameters for testing the service are stored.'
                                 'Defaults to "test_services.cfg"')
        parser.add_argument('--account_username', dest='account_username', type=str,
                            help='Username of the account which has linked its Audio Commons Mediator account with a'
                                 'third party account. This is only needed to test components which required end user'
                                 'authentication.')

    def handle(self, *args, **options):
        """
        Iterate over all implemented components by the given service and test them. Output an HTML report
        with the results. Loads configuration parameters for the tests (e.g. query terms) from a file called
        `test_services.cfg` that should be placed in the same directory.
        """

        service_name = options['service_name']

# Path: accounts/models.py
# class Account(AbstractUser):
#     """
#     This is our custom 'User' model.
#     """
# 
#     is_developer = models.BooleanField(default=False, blank=False)
#     accepted_tos = models.BooleanField(default=False, blank=False)
#     #  Add more custom fields here like avatar...
# 
#     def send_activation_email(self):
#         tvars = {
#             'user': self,
#             'username': self.username,
#             'hash': create_hash(self.id)
#         }
#         send_mail(self.email, subject='Activate your Audio Commons user account',
#                   template='emails/account_activation.txt', context=tvars)
# 
#     class Meta:
#         verbose_name = _('account')
#         verbose_name_plural = _('accounts')
# 
# Path: services/mgmt.py
# def get_service_by_name(service_name):
#     for service in available_services:
#         if service.name == service_name:
#             return service
#     raise ACServiceDoesNotExist('Service with name {0} does not exist'.format(service_name))


# Path: services/management/commands/test_service.py
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from accounts.models import Account
from services.acservice.constants import *
from ac_mediator.exceptions import *
from services.mgmt import get_service_by_name
import configparser
import os
import logging
import json

    return {
        'status': 'IN',
        'response': 'Invalid or not supported component'
    }


class Command(BaseCommand):
    help = 'Test an implementation of a 3rd party service integration with the Audio Commons Mediator.'

    def add_arguments(self, parser):
        parser.add_argument('service_name', type=str, help='Name or id of the service to test')
        parser.add_argument('--out_filename', dest='out_filename', type=str,
                            help='Filename where to save the output of the test. '
                                 'Defaults to "out_test_<SERVICE_NAME>.html"')
        parser.add_argument('--test_config_filename', dest='test_config_filename', type=str,
                            help='Filename where to configuration parameters for testing the service are stored.'
                                 'Defaults to "test_services.cfg"')
        parser.add_argument('--account_username', dest='account_username', type=str,
                            help='Username of the account which has linked its Audio Commons Mediator account with a'
                                 'third party account. This is only needed to test components which required end user'
                                 'authentication.')

    def handle(self, *args, **options):
        """
        Iterate over all implemented components by the given service and test them. Output an HTML report
        with the results. Loads configuration parameters for the tests (e.g. query terms) from a file called
        `test_services.cfg` that should be placed in the same directory.
        """

        service_name = options['service_name']

        service = get_service_by_name(service_name)