import uuid

from django.test import TestCase

from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.db import IntegrityError

from .models import RawAction


class RawActionTest(TestCase):
	
	def setUp(self):
		self.user = get_user_model().objects.create(username='abc')
		self.action = RawAction.objects.create(
			session_key='12345',
			user=self.user,
			)
	
	def test_fields(self):
		self.assertEquals(self.action.user, self.user)
		self.assertIsNotNone(self.action.session_key)
	
	def test_properties(self):
		self.assertEquals(self.action.user_id, self.user.id)
	
	def test_session_key_is_not_nullable(self):
		self.action.session_key = None
		with self.assertRaises(IntegrityError):
			self.action.save()
	
	def test_user_is_nullable(self):
		self.action.user = None
		self.action.save()

@@ -246,31 +246,89 @@
 %0A%09%0A%09
-def setUp(self):%0A%09%09self
+@classmethod%0A%09def setUpClass(cls):%0A%09%09super(RawActionTest, cls).setUpClass()%0A%09%09cls
 .use
@@ -379,16 +379,36 @@
 ='abc')%0A
+%09%0A%09def setUp(self):%0A
 %09%09self.a

move user creation to class method for performance