<commit_before>from django.utils import unittest
from spotseeker_server.default_forms.spot import DefaultSpotForm
from spotseeker_server.forms.spot import SpotForm
from django.conf import settings


class SpotFormTest(unittest.TestCase):
    settings.SPOTSEEKER_AUTH_MODULE = 'spotseeker_server.auth.all_ok'
    settings.SPOTSEEKER_SPOT_FORM = 'spotseeker_server.default_forms.spot.DefaultSpotForm'

    def test_default(self):
        form = SpotForm({})
        self.assertEqual(form.__class__, DefaultSpotForm({}).__class__, "Tests shouldn't be run with a defined SPOTSEEKER_SPOT_FORM")

    def test_errors(self):
        form = SpotForm({})
        errors = form.errors
        self.assertTrue("name" in errors, "Default spot form requires a spot name")
        self.assertFalse("capacity" in errors, "Default spot form doesn't require a spot name")<commit_msg>Moved spot form tests to explicitly use the all_ok auth module and DefaultSpotForm just in the scope of the tests regardless of what is set in the settings.py.<commit_after>from django.test import TestCase
from spotseeker_server.default_forms.spot import DefaultSpotForm
from spotseeker_server.forms.spot import SpotForm
from django.conf import settings


class SpotFormTest(TestCase):

    def test_default(self):
        with self.settings(SPOTSEEKER_AUTH_MODULE='spotseeker_server.auth.all_ok',
                           SPOTSEEKER_SPOT_FORM='spotseeker_server.default_forms.spot.DefaultSpotForm'):
            form = SpotForm({})
            self.assertEqual(form.__class__, DefaultSpotForm({}).__class__, "Tests shouldn't be run with a defined SPOTSEEKER_SPOT_FORM")

    def test_errors(self):
        with self.settings(SPOTSEEKER_AUTH_MODULE='spotseeker_server.auth.all_ok',
                           SPOTSEEKER_SPOT_FORM='spotseeker_server.default_forms.spot.DefaultSpotForm'):
            form = SpotForm({})
            errors = form.errors
            self.assertTrue("name" in errors, "Default spot form requires a spot name")
            self.assertFalse("capacity" in errors, "Default spot form doesn't require a spot name")
{'fraction_non_alphanumeric': 0.08068343616516374, 'fraction_numerical': 0.0, 'mean_word_length': 3.902325581395349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3850689', 'n_tokens_mistral': 601, 'n_tokens_neox': 584, 'n_words': 154}