<commit_before>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from datetime import datetime, timedelta
from django.test import TestCase
from django.contrib.auth.models import User
from django.utils.timezone import utc
from threads.models import UserProfile, Thread, Message

from events.models import Event

class TestEvent(TestCase):
	def setUp(self):
		self.u = User.objects.create_user(username="u", email="<EMAIL>", password="<PASSWORD>")
		self.u.save()

		profile = UserProfile.objects.get(user=self.u)
		now = datetime.utcnow().replace(tzinfo=utc)
		one_day = timedelta(days=1)

		self.ev = Event(owner=profile, title="Event Title Test",
				start_time=now, end_time=now + one_day)
		self.ev.save()

		self.client.login(username="u", password="<PASSWORD>")

	def test_event_views(self):
		urls = [
			"/events/",
			"/archives/all_events/",
			]
		for url in urls:
			response = self.client.get(url)
			self.assertEqual(response.status_code, 200)
			self.assertIn(self.ev.title, response.content)
<commit_msg>Added test_rsvp<commit_after>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from datetime import datetime, timedelta
from django.test import TestCase
from django.contrib.auth.models import User
from django.utils.timezone import utc
from threads.models import UserProfile, Thread, Message

from events.models import Event

class TestEvent(TestCase):
	def setUp(self):
		self.u = User.objects.create_user(username="u", email="<EMAIL>", password="<PASSWORD>")
		self.u.save()

		profile = UserProfile.objects.get(user=self.u)
		now = datetime.utcnow().replace(tzinfo=utc)
		one_day = timedelta(days=1)

		self.ev = Event(owner=profile, title="Event Title Test",
				start_time=now, end_time=now + one_day)
		self.ev.save()

		self.client.login(username="u", password="<PASSWORD>")

	def test_event_views(self):
		urls = [
			"/events/",
			"/archives/all_events/",
			]
		for url in urls:
			response = self.client.get(url)
			self.assertEqual(response.status_code, 200)
			self.assertIn(self.ev.title, response.content)

	def test_rsvp(self):
		urls = [
			"/events/",
			"/archives/all_events/",
			]
		for url in urls:
			response = self.client.post(url, {
					"rsvp": "",
					"event_pk": "{0}".format(self.ev.pk),
					}, follow=True)
			self.assertRedirects(response, url)
			self.assertIn('title="Un-RSVP"', response.content)

			response = self.client.post(url, {
					"rsvp": "",
					"event_pk": "{0}".format(self.ev.pk),
					}, follow=True)
			self.assertRedirects(response, url)
			self.assertIn('title="RSVP"', response.content)
{'fraction_non_alphanumeric': 0.13745583038869258, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 4.413001912045889, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, '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': '1596427', 'n_tokens_mistral': 1041, 'n_tokens_neox': 923, 'n_words': 220}