# Path: ACM_General/events/forms.py
# class EventForm(ModelForm):
#     """
#     This class is used for combining the Event Class model with a form
#     (ModelForm).
#     """
#     class Meta:
#         model = Event
#         exclude = ('id', 'creator', 'date_created')
#         widgets = {
#             'date_hosted': DateTimeInput(attrs={'id': 'calendar'}),
#             'date_expire': DateTimeInput(attrs={'id': 'calendar'}),
#             'title': Textarea(attrs={'rows': 3}),
#             'description': Textarea(attrs={'rows': 3}),
#             'link': TextInput(),
#         }


from datetime import datetime
from io import BytesIO
from PIL import Image
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import transaction
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from . import models
from .forms import EventForm
from accounts.models import User
from sigs.models import SIG
import os
import tempfile
        # https://stackoverflow.com/questions/48075739/unit-testing-a-django-form-with-a-imagefield-without-external-file.
        im_io = BytesIO()
        im = Image.new(mode='RGB', size=(50, 50))
        im.save(im_io, 'JPEG')
        # Sets up image variable for creating Event
        self.image = SimpleUploadedFile(
            name='test_image.jpg',
            content=im_io.getvalue(),
            content_type='multipart/form-data'
        )

        # Test data for filling the event form
        self.data = {
            'creator': self.user,
            'date_hosted': timezone.now() + timezone.timedelta(days=1),
            'date_expire': timezone.now() + timezone.timedelta(days=2),
            'hosting_sig': self.sig,
            'title': 'Test Title',
            'description': 'Here is a test description',
            'location': 'CS 207',
            'presenter': 'test',
            'cost': 10.00,
            'link': 'acm.mst.edu'
        }

        self.image_data = {'flier': self.image}
        super().setUp()

    def test_event_form_with_valid_data(self):
        # Adds data to EventForm and checks that all data is valid

# Path: ACM_General/events/forms.py
# class EventForm(ModelForm):
#     """
#     This class is used for combining the Event Class model with a form
#     (ModelForm).
#     """
#     class Meta:
#         model = Event
#         exclude = ('id', 'creator', 'date_created')
#         widgets = {
#             'date_hosted': DateTimeInput(attrs={'id': 'calendar'}),
#             'date_expire': DateTimeInput(attrs={'id': 'calendar'}),
#             'title': Textarea(attrs={'rows': 3}),
#             'description': Textarea(attrs={'rows': 3}),
#             'link': TextInput(),
#         }


# Path: ACM_General/events/tests.py
from datetime import datetime
from io import BytesIO
from PIL import Image
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import transaction
from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from . import models
from .forms import EventForm
from accounts.models import User
from sigs.models import SIG
import os
import tempfile

        # https://stackoverflow.com/questions/48075739/unit-testing-a-django-form-with-a-imagefield-without-external-file.
        im_io = BytesIO()
        im = Image.new(mode='RGB', size=(50, 50))
        im.save(im_io, 'JPEG')
        # Sets up image variable for creating Event
        self.image = SimpleUploadedFile(
            name='test_image.jpg',
            content=im_io.getvalue(),
            content_type='multipart/form-data'
        )

        # Test data for filling the event form
        self.data = {
            'creator': self.user,
            'date_hosted': timezone.now() + timezone.timedelta(days=1),
            'date_expire': timezone.now() + timezone.timedelta(days=2),
            'hosting_sig': self.sig,
            'title': 'Test Title',
            'description': 'Here is a test description',
            'location': 'CS 207',
            'presenter': 'test',
            'cost': 10.00,
            'link': 'acm.mst.edu'
        }

        self.image_data = {'flier': self.image}
        super().setUp()

    def test_event_form_with_valid_data(self):
        # Adds data to EventForm and checks that all data is valid

        test_form = EventForm(self.data, self.image_data)