# Path: wsse/server/default/tests/test_store.py
# class TestSQLiteNonceStore(TestCase):
# 	def setUpClass(cls):
# 	def tearDown(self):
# 	def count_nonces(self):
# 	def get_nonces(self):
# 	def add_nonce(self, nonce, ts):
# 	def db_query(self, query, *args, **kwargs):
# 	def test_add_nonce(self):
# 	def test_add_nonce_multiple(self):
# 	def test_has_nonce(self):
# 	def tear_clear(self):
# 	def test_clean_expired_nonces(self):
# 
# Path: wsse/server/django/wsse/store.py
# class DjangoNonceStore(object):
# 	def add_nonce(self, nonce, timestamp = None):
# 	def has_nonce(self, nonce):
# 	def clean_expired_nonces(self):
# 
# Path: wsse/server/django/wsse/models.py
# class WSSEEvent(models.Model):
# 	'''
# 	The `WSSEEvent` object records an event that occured with the WSSE
# 	authentication. Specifically, it records when a nonce was used to prevent
# 	immediate re-use. 
# 	'''
# 	nonce = models.CharField(max_length = settings.NONCE_LENGTH, db_index = True)
# 
# 	# We cannot use `auto_now_add = True` here because the timezone for that
# 	# is not explicitly known. Instead, we default to using the current time in
# 	# UTC, which guarantees the timezone, especially because all the timestamps
# 	# are stored in UTC.
# 	timestamp = models.DateTimeField(default = timezone.now, db_index = True)


from django.test import TransactionTestCase
from wsse.server.default.tests import test_store
from wsse.server.django.wsse import store
from wsse.server.django.wsse.models import WSSEEvent


class TestDjangoNonceStore(TransactionTestCase,
	test_store.TestSQLiteNonceStore):
	'''
	Test the `store.DjangoNonceStore` class.
	'''
	@classmethod
	def setUpClass(cls):
		'''
		Set up the class for running tests.
		'''
		cls.store = store.DjangoNonceStore()

	def count_nonces(self):
		'''
		Count the number of nonces in the database.

		:return: number of nonces in the database
		:rtype: int
		'''
		return WSSEEvent.objects.count()

	def get_nonces(self):
		'''
		Get all nonces from the database.

		:return: nonces in the database
		:rtype: list
		'''

# Path: wsse/server/default/tests/test_store.py
# class TestSQLiteNonceStore(TestCase):
# 	def setUpClass(cls):
# 	def tearDown(self):
# 	def count_nonces(self):
# 	def get_nonces(self):
# 	def add_nonce(self, nonce, ts):
# 	def db_query(self, query, *args, **kwargs):
# 	def test_add_nonce(self):
# 	def test_add_nonce_multiple(self):
# 	def test_has_nonce(self):
# 	def tear_clear(self):
# 	def test_clean_expired_nonces(self):
# 
# Path: wsse/server/django/wsse/store.py
# class DjangoNonceStore(object):
# 	def add_nonce(self, nonce, timestamp = None):
# 	def has_nonce(self, nonce):
# 	def clean_expired_nonces(self):
# 
# Path: wsse/server/django/wsse/models.py
# class WSSEEvent(models.Model):
# 	'''
# 	The `WSSEEvent` object records an event that occured with the WSSE
# 	authentication. Specifically, it records when a nonce was used to prevent
# 	immediate re-use. 
# 	'''
# 	nonce = models.CharField(max_length = settings.NONCE_LENGTH, db_index = True)
# 
# 	# We cannot use `auto_now_add = True` here because the timezone for that
# 	# is not explicitly known. Instead, we default to using the current time in
# 	# UTC, which guarantees the timezone, especially because all the timestamps
# 	# are stored in UTC.
# 	timestamp = models.DateTimeField(default = timezone.now, db_index = True)


# Path: wsse/server/django/tests/test_store.py
from django.test import TransactionTestCase
from wsse.server.default.tests import test_store
from wsse.server.django.wsse import store
from wsse.server.django.wsse.models import WSSEEvent



class TestDjangoNonceStore(TransactionTestCase,
	test_store.TestSQLiteNonceStore):
	'''
	Test the `store.DjangoNonceStore` class.
	'''
	@classmethod
	def setUpClass(cls):
		'''
		Set up the class for running tests.
		'''
		cls.store = store.DjangoNonceStore()

	def count_nonces(self):
		'''
		Count the number of nonces in the database.

		:return: number of nonces in the database
		:rtype: int
		'''
		return WSSEEvent.objects.count()

	def get_nonces(self):
		'''
		Get all nonces from the database.

		:return: nonces in the database
		:rtype: list
		'''

		return list(WSSEEvent.objects.all().values_list('nonce', flat = True))