# Path: quotes/tests/utils.py
# def create_multiple_test_tags(ammount=100):
#     tags = []
#     for i in xrange(ammount):
#         name = "Tag %d" % i
#         tag = Tag.objects.create(name=name)
#         tags.append(tag)
#     now = datetime.now()
#     for i in xrange(10):
#         body = 'Test quote %d' % i
#         quote = Quote.objects.create(body=body, publish_date=now)
#         quote.tags.add(tags[0])
#     return tags


from lxml import html
from django.test import TestCase
from django.test.client import Client
from quotes.tests.utils import create_multiple_test_tags
# coding: utf-8




class TagsPageTestCase(TestCase):

    def setUp(self):
        self.client = Client()
        self.dom = ''

    def tearDown(self):
        self.dom = ''

    def __load_dom(self):
        response = self.client.get('/tags/')
        self.dom = html.fromstring(response.content)

    def testTagsPageResponse(self):
        response = self.client.get('/tags/')
        self.failUnlessEqual(response.status_code, 200)

    def testTagsPageShouldShowTags(self):
        self.tags = create_multiple_test_tags()
        self.__load_dom()
        tags_list = self.dom.cssselect('#tags-list li')
        assert len(tags_list), 100

    def testTagNameShouldHaveQuotesCount(self):

# Path: quotes/tests/utils.py
# def create_multiple_test_tags(ammount=100):
#     tags = []
#     for i in xrange(ammount):
#         name = "Tag %d" % i
#         tag = Tag.objects.create(name=name)
#         tags.append(tag)
#     now = datetime.now()
#     for i in xrange(10):
#         body = 'Test quote %d' % i
#         quote = Quote.objects.create(body=body, publish_date=now)
#         quote.tags.add(tags[0])
#     return tags


# Path: quotes/tests/requests/test_tags_page.py
from lxml import html
from django.test import TestCase
from django.test.client import Client
from quotes.tests.utils import create_multiple_test_tags

# coding: utf-8




class TagsPageTestCase(TestCase):

    def setUp(self):
        self.client = Client()
        self.dom = ''

    def tearDown(self):
        self.dom = ''

    def __load_dom(self):
        response = self.client.get('/tags/')
        self.dom = html.fromstring(response.content)

    def testTagsPageResponse(self):
        response = self.client.get('/tags/')
        self.failUnlessEqual(response.status_code, 200)

    def testTagsPageShouldShowTags(self):
        self.tags = create_multiple_test_tags()
        self.__load_dom()
        tags_list = self.dom.cssselect('#tags-list li')
        assert len(tags_list), 100

    def testTagNameShouldHaveQuotesCount(self):

        self.tags = create_multiple_test_tags()