# Path: appointment/test_forms.py
# def apt_dict():
#     apt = {'clindate': now().date(),
#            'clintime': time(9, 0),
#            'appointment_type': 'PSYCH_NIGHT',
#            'comment': 'stuff',
#            'author': Provider.objects.first(),
#            'author_type': ProviderType.objects.first(),
#            'patient': Patient.objects.first().id}
# 
#     return(apt)


from builtins import range
from datetime import timedelta, time
from django.test import TestCase
from django.utils.timezone import now
from django.core.urlresolvers import reverse
from pttrack.models import Provider, ProviderType, Patient
from pttrack.test_views import log_in_provider, build_provider
from .test_forms import apt_dict
from . import models
import re

        self.apt = models.Appointment.objects.create(
            comment='test this stuff',
            clindate=now().date(),
            clintime=time(9, 0),
            appointment_type='PSYCH_NIGHT',
            author=Provider.objects.first(),
            author_type=ProviderType.objects.filter(signs_charts=False).first(),
            patient=Patient.objects.first())

    def test_new_appointment_view(self):
        # Getting to new appointment view
        response = self.client.get(reverse("appointment-new"))
        self.assertEqual(response.status_code, 200)

        # Posting new appointment
        response = self.client.post(reverse("appointment-new"), data=apt_dict())
        self.assertEqual(response.status_code, 302)

    def test_update_appointment_view(self):
        apt = models.Appointment.objects.first()

        # Getting to appointment update view
        response = self.client.get(reverse("appointment-update",
                                   kwargs={'pk': apt.pk}))
        self.assertEqual(response.status_code, 200)

        # Posting updated appointment
        self.assertEqual(apt.comment, 'test this stuff')
        response = self.client.post(reverse('appointment-update',

# Path: appointment/test_forms.py
# def apt_dict():
#     apt = {'clindate': now().date(),
#            'clintime': time(9, 0),
#            'appointment_type': 'PSYCH_NIGHT',
#            'comment': 'stuff',
#            'author': Provider.objects.first(),
#            'author_type': ProviderType.objects.first(),
#            'patient': Patient.objects.first().id}
# 
#     return(apt)


# Path: appointment/test_views.py
from builtins import range
from datetime import timedelta, time
from django.test import TestCase
from django.utils.timezone import now
from django.core.urlresolvers import reverse
from pttrack.models import Provider, ProviderType, Patient
from pttrack.test_views import log_in_provider, build_provider
from .test_forms import apt_dict
from . import models
import re


        self.apt = models.Appointment.objects.create(
            comment='test this stuff',
            clindate=now().date(),
            clintime=time(9, 0),
            appointment_type='PSYCH_NIGHT',
            author=Provider.objects.first(),
            author_type=ProviderType.objects.filter(signs_charts=False).first(),
            patient=Patient.objects.first())

    def test_new_appointment_view(self):
        # Getting to new appointment view
        response = self.client.get(reverse("appointment-new"))
        self.assertEqual(response.status_code, 200)

        # Posting new appointment
        response = self.client.post(reverse("appointment-new"), data=apt_dict())
        self.assertEqual(response.status_code, 302)

    def test_update_appointment_view(self):
        apt = models.Appointment.objects.first()

        # Getting to appointment update view
        response = self.client.get(reverse("appointment-update",
                                   kwargs={'pk': apt.pk}))
        self.assertEqual(response.status_code, 200)

        # Posting updated appointment
        self.assertEqual(apt.comment, 'test this stuff')
        response = self.client.post(reverse('appointment-update',

                                    kwargs={'pk': apt.pk}), data=apt_dict())