<commit_before>from django.test import TestCase
from django.contrib import admin

from ..schema import get_schema
from ..models import Schema, User
from .models import AwareModel

class TestAdminAdditions(TestCase):
    def test_ensure_schema_schema_is_not_editable(self):
        Schema.objects.mass_create('a','b','c')
        
        user = User.objects.create_superuser(
            username="su",
            password="su",
            email="<EMAIL>"
        )
        
        self.client.login(username='su', password='su')
        response = self.client.get('/admin/multi_schema/schema/a/')
        form = response.context['adminform'].form
        self.assertTrue('name' in form.fields)
        self.assertTrue('schema' not in form.fields, 'Schema.schema should be read-only on edit.')
        
        response = self.client.get('/admin/multi_schema/schema/add/')
        form = response.context['adminform'].form
        self.assertTrue('name' in form.fields)
        self.assertTrue('schema' in form.fields, 'Schema.schema should be editable on create.')
        <commit_msg>Attempt to write a test for aware models in admin. We need to be adding the object to the admin before we can.<commit_after>import unittest

from django.test import TestCase
from django.contrib import admin
from django.core.urlresolvers import reverse

from ..schema import get_schema
from ..models import Schema, User
from .models import AwareModel

class TestAdminAdditions(TestCase):
    def test_ensure_schema_schema_is_not_editable(self):
        Schema.objects.mass_create('a','b','c')
        
        user = User.objects.create_superuser(
            username="su",
            password="su",
            email="<EMAIL>"
        )
        
        self.client.login(username='su', password='su')
        response = self.client.get('/admin/multi_schema/schema/a/')
        form = response.context['adminform'].form
        self.assertTrue('name' in form.fields)
        self.assertTrue('schema' not in form.fields, 'Schema.schema should be read-only on edit.')
        
        response = self.client.get('/admin/multi_schema/schema/add/')
        form = response.context['adminform'].form
        self.assertTrue('name' in form.fields)
        self.assertTrue('schema' in form.fields, 'Schema.schema should be editable on create.')
    
    @unittest.expectedFailure
    def test_schema_aware_models_when_no_schema_selected(self):
        Schema.objects.mass_create('a','b','c')
        
        user = User.objects.create_superuser(
            username="su",
            password="su",
            email="<EMAIL>"
        )
        
        self.client.login(username='su', password='su')
        response = self.client.get(reverse('/admin/multi_schema/aware/'))
{'fraction_non_alphanumeric': 0.11771097428467947, 'fraction_numerical': 0.0, 'mean_word_length': 2.7374830852503385, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3723899', 'n_tokens_mistral': 758, 'n_tokens_neox': 764, 'n_words': 173}