# Path: staticgen/models.py
# class LogEntry(models.Model):
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     page = models.ForeignKey(Page, blank=True, null=True, on_delete=models.CASCADE)
#     change_message = models.TextField(_('change message'))
#     action_time = models.DateTimeField(_('action time'), auto_now=True)
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = _('log entry')
#         verbose_name_plural = _('log entries')
#         ordering = ('-action_time',)
# 
#     def __str__(self):
#         return self.change_message
# 
# class Page(models.Model):
#     PUBLISHER_STATE_DEFAULT = 0
#     PUBLISHER_STATE_CHANGED = 1
#     PUBLISHER_STATE_PUBLISHED = 2
#     PUBLISHER_STATE_ERROR = 3
#     PUBLISHER_STATE_DELETE = 4
# 
#     PUBLISHER_STATES = (
#         (PUBLISHER_STATE_DEFAULT, _('Pending')),
#         (PUBLISHER_STATE_CHANGED, _('Changed')),
#         (PUBLISHER_STATE_PUBLISHED, _('Published')),
#         (PUBLISHER_STATE_ERROR, _('Error')),
#         (PUBLISHER_STATE_DELETE, _('Deleted'))
#     )
# 
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     path = models.CharField(_('URL'), max_length=255)
#     publisher_state = models.SmallIntegerField(
#         _('State'), choices=PUBLISHER_STATES, default=PUBLISHER_STATE_DEFAULT,
#         editable=False, db_index=True)
#     updated_at = models.DateTimeField(auto_now=True)
#     objects = PageManager()
# 
#     class Meta:
#         verbose_name = _('page')
#         verbose_name_plural = _('pages')
#         ordering = ('path', )
#         unique_together = ('site', 'path')
# 
#     def __str__(self):
#         return self.path
# 
#     @property
#     def has_changed(self):
#         return self.publisher_state == self.PUBLISHER_STATE_CHANGED


from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.encoding import force_text
from mock import patch
from staticgen.models import LogEntry, Page
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals




class TestStaticgenPageAdmin(TestCase):

    def setUp(self):
        for id in range(1, 6):
            path = '/page{0}/'.format(id)
            page = Page.objects.create(
                pk=id,
                path=path, site_id=settings.SITE_ID,
                publisher_state=Page.PUBLISHER_STATE_PUBLISHED)
            change_message = 'Added page {page}'.format(page=force_text(page))
            LogEntry.objects.log_action(change_message, page_id=id)


# Path: staticgen/models.py
# class LogEntry(models.Model):
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     page = models.ForeignKey(Page, blank=True, null=True, on_delete=models.CASCADE)
#     change_message = models.TextField(_('change message'))
#     action_time = models.DateTimeField(_('action time'), auto_now=True)
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = _('log entry')
#         verbose_name_plural = _('log entries')
#         ordering = ('-action_time',)
# 
#     def __str__(self):
#         return self.change_message
# 
# class Page(models.Model):
#     PUBLISHER_STATE_DEFAULT = 0
#     PUBLISHER_STATE_CHANGED = 1
#     PUBLISHER_STATE_PUBLISHED = 2
#     PUBLISHER_STATE_ERROR = 3
#     PUBLISHER_STATE_DELETE = 4
# 
#     PUBLISHER_STATES = (
#         (PUBLISHER_STATE_DEFAULT, _('Pending')),
#         (PUBLISHER_STATE_CHANGED, _('Changed')),
#         (PUBLISHER_STATE_PUBLISHED, _('Published')),
#         (PUBLISHER_STATE_ERROR, _('Error')),
#         (PUBLISHER_STATE_DELETE, _('Deleted'))
#     )
# 
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     path = models.CharField(_('URL'), max_length=255)
#     publisher_state = models.SmallIntegerField(
#         _('State'), choices=PUBLISHER_STATES, default=PUBLISHER_STATE_DEFAULT,
#         editable=False, db_index=True)
#     updated_at = models.DateTimeField(auto_now=True)
#     objects = PageManager()
# 
#     class Meta:
#         verbose_name = _('page')
#         verbose_name_plural = _('pages')
#         ordering = ('path', )
#         unique_together = ('site', 'path')
# 
#     def __str__(self):
#         return self.path
# 
#     @property
#     def has_changed(self):
#         return self.publisher_state == self.PUBLISHER_STATE_CHANGED


# Path: tests/test_admin.py
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.encoding import force_text
from mock import patch
from staticgen.models import LogEntry, Page

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals




class TestStaticgenPageAdmin(TestCase):

    def setUp(self):
        for id in range(1, 6):
            path = '/page{0}/'.format(id)
            page = Page.objects.create(
                pk=id,
                path=path, site_id=settings.SITE_ID,
                publisher_state=Page.PUBLISHER_STATE_PUBLISHED)
            change_message = 'Added page {page}'.format(page=force_text(page))
            LogEntry.objects.log_action(change_message, page_id=id)


        LogEntry.objects.log_action('Change message', site_id=settings.SITE_ID)