# Path: competencies/views.py
# def organization(request, organization_id):
#     """Displays subject areas and subdiscipline areas for a given organization."""
#     organization = Organization.objects.get(id=organization_id)
#     editors = organization.editors.all()
#     if organization.subjectarea_set.all():
#         can_fork = False
#     else:
#         can_fork = True
#     kwargs = get_visibility_filter(request.user, organization)
#     sas = organization.subjectarea_set.filter(**kwargs)
#     sdas = [sda for sa in sas for sda in sa.subdisciplinearea_set.filter(**kwargs)]    
#     return render_to_response('competencies/organization.html',
#                               {'organization': organization, 'subject_areas': sas,
#                                'sdas': sdas, 'can_fork': can_fork,
#                                'editors': editors,
#                                },
#                               context_instance=RequestContext(request))
# 
# Path: competencies/my_admin.py
# def add_userprofile(user):
# def initialize_data():
# def build_test_schools(num_elements=2):
# 
# Path: competencies/utils.py
# def cascade_visibility_down(element, visibility_mode):
# def cascade_public_up(element):
# def fork_organization(forking_org, original_org):
# 
# Path: users/models.py
# class UserProfile(models.Model):
#     """Was here to manage m2m relation to Organization."""
#     # Keeping this, because I'll store more information about users at some point.
#     user = models.OneToOneField(User)


from random import choice
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from competencies.models import *
from competencies.views import organization
from competencies import my_admin, utils
from users.models import UserProfile
     https://docs.djangoproject.com/en/1.8/topics/testing/overview/#writing-tests

    Not sure why I need __init__.py.
     Shouldn't test utility find any class under /tests that inherits from TestCase?
     Why do the tests in other modules like test_forms.py run?

"""

class CompetencyViewTests(TestCase):
    """Tests for all views in competencies."""
    # May want to use simpler password hashing in tests.
    #  https://docs.djangoproject.com/en/1.8/topics/testing/overview/#speeding-up-the-tests

    # setUp() should build an organization, but then have separate methods to
    #  build the organization out to subject area levels, sda, grad std, or perf indicator.
    # Then each test method can only call the level it needs. Testing efficiency
    #  should be greatly improved. Methdods such as build_to_sas(), build_to_eus().

    def setUp(self):
        # Build an organization, down to the performance indicator level.
        self.num_orgs = 2
        self.num_elements = 2
        self.client = Client()

        # Create 2 test users.
        self.test_user_0 = User.objects.create_user(username='testuser0', password='pw')
        new_up = UserProfile(user=self.test_user_0)
        new_up.save()

        self.test_user_1 = User.objects.create_user(username='testuser1', password='pw')

# Path: competencies/views.py
# def organization(request, organization_id):
#     """Displays subject areas and subdiscipline areas for a given organization."""
#     organization = Organization.objects.get(id=organization_id)
#     editors = organization.editors.all()
#     if organization.subjectarea_set.all():
#         can_fork = False
#     else:
#         can_fork = True
#     kwargs = get_visibility_filter(request.user, organization)
#     sas = organization.subjectarea_set.filter(**kwargs)
#     sdas = [sda for sa in sas for sda in sa.subdisciplinearea_set.filter(**kwargs)]    
#     return render_to_response('competencies/organization.html',
#                               {'organization': organization, 'subject_areas': sas,
#                                'sdas': sdas, 'can_fork': can_fork,
#                                'editors': editors,
#                                },
#                               context_instance=RequestContext(request))
# 
# Path: competencies/my_admin.py
# def add_userprofile(user):
# def initialize_data():
# def build_test_schools(num_elements=2):
# 
# Path: competencies/utils.py
# def cascade_visibility_down(element, visibility_mode):
# def cascade_public_up(element):
# def fork_organization(forking_org, original_org):
# 
# Path: users/models.py
# class UserProfile(models.Model):
#     """Was here to manage m2m relation to Organization."""
#     # Keeping this, because I'll store more information about users at some point.
#     user = models.OneToOneField(User)


# Path: competencies/tests/test_views.py
from random import choice
from django.test import TestCase
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from competencies.models import *
from competencies.views import organization
from competencies import my_admin, utils
from users.models import UserProfile

     https://docs.djangoproject.com/en/1.8/topics/testing/overview/#writing-tests

    Not sure why I need __init__.py.
     Shouldn't test utility find any class under /tests that inherits from TestCase?
     Why do the tests in other modules like test_forms.py run?

"""

class CompetencyViewTests(TestCase):
    """Tests for all views in competencies."""
    # May want to use simpler password hashing in tests.
    #  https://docs.djangoproject.com/en/1.8/topics/testing/overview/#speeding-up-the-tests

    # setUp() should build an organization, but then have separate methods to
    #  build the organization out to subject area levels, sda, grad std, or perf indicator.
    # Then each test method can only call the level it needs. Testing efficiency
    #  should be greatly improved. Methdods such as build_to_sas(), build_to_eus().

    def setUp(self):
        # Build an organization, down to the performance indicator level.
        self.num_orgs = 2
        self.num_elements = 2
        self.client = Client()

        # Create 2 test users.
        self.test_user_0 = User.objects.create_user(username='testuser0', password='pw')
        new_up = UserProfile(user=self.test_user_0)
        new_up.save()

        self.test_user_1 = User.objects.create_user(username='testuser1', password='pw')

        new_up = UserProfile(user=self.test_user_1)