<commit_before>import datetime
import mock

from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.test import TestCase

from myvoice.core.tests import factories
from myvoice.statistics import models as statistics

from .. import models


class TestClinic(TestCase):
    Model = models.Clinic
    Factory = factories.Clinic

    def test_unicode(self):
        """Smoke test for Clinic string representation."""
        obj = self.Factory.create(name='Hello')
        self.assertEqual(str(obj), 'Hello')


class TestClinicStaff(TestCase):
    Model = models.ClinicStaff
    Factory = factories.ClinicStaff

    def test_unicode(self):
        """Smoke test for ClinicStaff string representation."""
        obj = self.Factory.create(name='Hello')
        self.assertEqual(str(obj), 'Hello')

    def test_get_name_display_user(self):
        """User name should be preferred to 'name' field on a staff member."""
        obj = self.Factory.create(
            user=factories.User(first_name='a', last_name='b'),
            name='hello')
        self.assertEqual(obj.get_name_display(), 'a b')

    def test_get_name_display_no_user(self):
        """If staff member has no associated user, 'name' field should be used."""
        obj = self.Factory.create(name='hello')
        self.assertEqual(obj.get_name_display(), 'hello')


class TestService(TestCase):
    Model = models.Service
    Factory = factories.Service

    def test_unicode(self):
        obj = self.Factory.create(name='hello')
        self.assertEqual(str(obj), 'hello')


class TestPatient(TestCase):
    Model = models.Patient
    Factory = factories.Patient

    def test_unicode(self):
        """Smoke test for Patient string representation."""
        obj = self.Factory.create(serial=5, clinic__name='Hello')
        self.assertEqual(str(obj), '5 at Hello')

    def test_get_name_display(self):
        """Contact name should be preferred to 'name' field on patient."""
        obj = self.Factory.create(
            name='test',
            contact=factories.Contact(name='test contact'))
        self.assertEqual(obj.get_name_display(), "test contact")

    def test_get_name_no_contact(self):
        """Show name if no contact attached to patient."""
        obj = self.Factory.create(name='test')
        self.assertEqual(obj.get_name_display(), 'test')


class TestVisit(TestCase):
    Model = models.Visit
    Factory = factories.Visit

    def test_unicode(self):
        """Smoke test for Visit string representation."""
        obj = self.Factory.create(
            patient=factories.Patient(serial=5, clinic__name='Hello'),
            service=factories.Service(name='test_service'))
        self.assertEqual(str(obj), '5 at Hello')


class TestClinicStatistic(TestCase):
    Model = models.ClinicStatistic
    Factory = factories.ClinicStatistic

    def test_unicode(self):
        """Smoke test for ClinicStatistic string representation."""
        # Manually construct object to have more control over statistic type.
        #statistic = factories.Statistic.create(statistic_type=statistics.Statistic.TEXT)
        obj = self.Factory.create(
            clinic__name='Hello',
            month=datetime.date(2012, 10, 1),
            statistic__statistic_type=statistics.Statistic.TEXT,
            statistic__name='Test Stat',)
        self.assertEqual(str(obj), 'Test Stat for Hello for October 2012')

    def test_get_month_display(self):
        """Smoke test for month display method."""
        obj = self.Factory.create(month=datetime.date(2012, 10, 1))
        result = obj.get_month_display()
        self.assertEqual(result, 'October 2012')

    def test_get_month_display_custom(self):
        """Smoke test for month display method."""
        obj = self.Factory.create(month=datetime.date(2012, 10, 1))
        result = obj.get_month_display('%d %b %Y')<commit_msg>remove extra lines in clinic model tests<commit_after>import datetime
import mock

from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.test import TestCase

from myvoice.core.tests import factories
from myvoice.statistics import models as statistics

from .. import models


class TestClinic(TestCase):
    Model = models.Clinic
    Factory = factories.Clinic

    def test_unicode(self):
        """Smoke test for Clinic string representation."""
        obj = self.Factory.create(name='Hello')
        self.assertEqual(str(obj), 'Hello')


class TestClinicStaff(TestCase):
    Model = models.ClinicStaff
    Factory = factories.ClinicStaff

    def test_unicode(self):
        """Smoke test for ClinicStaff string representation."""
        obj = self.Factory.create(name='Hello')
        self.assertEqual(str(obj), 'Hello')

    def test_get_name_display_user(self):
        """User name should be preferred to 'name' field on a staff member."""
        obj = self.Factory.create(
            user=factories.User(first_name='a', last_name='b'),
            name='hello')
        self.assertEqual(obj.get_name_display(), 'a b')

    def test_get_name_display_no_user(self):
        """If staff member has no associated user, 'name' field should be used."""
        obj = self.Factory.create(name='hello')
        self.assertEqual(obj.get_name_display(), 'hello')


class TestService(TestCase):
    Model = models.Service
    Factory = factories.Service

    def test_unicode(self):
        obj = self.Factory.create(name='hello')
        self.assertEqual(str(obj), 'hello')


class TestPatient(TestCase):
    Model = models.Patient
    Factory = factories.Patient

    def test_unicode(self):
        """Smoke test for Patient string representation."""
        obj = self.Factory.create(serial=5, clinic__name='Hello')
        self.assertEqual(str(obj), '5 at Hello')

    def test_get_name_display(self):
        """Contact name should be preferred to 'name' field on patient."""
        obj = self.Factory.create(
            name='test',
            contact=factories.Contact(name='test contact'))
        self.assertEqual(obj.get_name_display(), "test contact")

    def test_get_name_no_contact(self):
        """Show name if no contact attached to patient."""
        obj = self.Factory.create(name='test')
        self.assertEqual(obj.get_name_display(), 'test')


class TestVisit(TestCase):
    Model = models.Visit
    Factory = factories.Visit

    def test_unicode(self):
        """Smoke test for Visit string representation."""
        obj = self.Factory.create(
            patient=factories.Patient(serial=5, clinic__name='Hello'),
            service=factories.Service(name='test_service'))
        self.assertEqual(str(obj), '5 at Hello')


class TestClinicStatistic(TestCase):
    Model = models.ClinicStatistic
    Factory = factories.ClinicStatistic

    def test_unicode(self):
        """Smoke test for ClinicStatistic string representation."""
        obj = self.Factory.create(
            clinic__name='Hello',
            month=datetime.date(2012, 10, 1),
            statistic__statistic_type=statistics.Statistic.TEXT,
            statistic__name='Test Stat',)
        self.assertEqual(str(obj), 'Test Stat for Hello for October 2012')

    def test_get_month_display(self):
        """Smoke test for month display method."""
        obj = self.Factory.create(month=datetime.date(2012, 10, 1))
        result = obj.get_month_display()
        self.assertEqual(result, 'October 2012')

    def test_get_month_display_custom(self):
        """Smoke test for month display method."""
        obj = self.Factory.create(month=datetime.date(2012, 10, 1))
        result = obj.get_month_display('%d %b %Y')
{'fraction_non_alphanumeric': 0.11345029239766082, 'fraction_numerical': 0.008576998050682261, 'mean_word_length': 3.187159956474429, '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': '4806487', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2077, 'n_words': 535}