charts test

This commit is contained in:
volpino 2012-05-07 10:56:54 +02:00
parent cb3dcaf713
commit 46489c84a4
3 changed files with 29 additions and 5 deletions

View File

@ -13,15 +13,15 @@ def random_string(length=10):
class HerdFactory(factory.Factory):
FACTORY_FOR = Herd
herd = 'Test Herd'
email = 'herd@testherd.com'
herd = factory.LazyAttribute(lambda a: random_string())
email = factory.LazyAttribute(lambda a: "%s@example.com" % a.herd)
class MaintainerFactory(factory.Factory):
FACTORY_FOR = Maintainer
herd = 'Test Maintainer'
email = 'maintainer@testmaintainer.com'
name = factory.LazyAttribute(lambda a: random_string())
email = factory.LazyAttribute(lambda a: "%s@example.com" % a.name)
class PackageFactory(factory.Factory):

View File

@ -1,4 +1,6 @@
from euscanwww.djeuscan.tests import SystemTestCase
from djeuscan.tests import SystemTestCase
from djeuscan.tests.euscan_factory import MaintainerFactory, HerdFactory, \
PackageFactory
class ChartTests(SystemTestCase):
@ -6,6 +8,12 @@ class ChartTests(SystemTestCase):
Test charts
"""
def setUp(self):
super(ChartTests, self).setUp()
self.a_herd = HerdFactory.create()
self.a_maintainer = MaintainerFactory.create()
self.a_category = PackageFactory.create().category
def test_statistics(self):
response = self.get("statistics")
self.assertEqual(response.status_code, 200)
@ -59,3 +67,18 @@ class ChartTests(SystemTestCase):
def test_versions_option_incorrect(self):
response = self.get("chart", chart="versions-trololol")
self.assertEqual(response.status_code, 404)
def test_herd(self):
response = self.get("chart_herd", chart="pie-packages",
herd=self.a_herd.herd)
self.assertEqual(response.status_code, 200)
def test_maintainer(self):
response = self.get("chart_maintainer", chart="pie-packages",
maintainer_id=self.a_maintainer.pk)
self.assertEqual(response.status_code, 200)
def test_category(self):
response = self.get("chart_category", chart="pie-packages",
category=self.a_category)
self.assertEqual(response.status_code, 200)

View File

@ -39,3 +39,4 @@ class EuscanResultModelTests(unittest.TestCase):
result1 = EuscanResultFactory.create(datetime=datetime(2012, 04, 01))
result2 = EuscanResultFactory.create(datetime=datetime(2012, 01, 01))
self.assertEqual(result1, EuscanResult.objects.latest())
self.assertNotEqual(result2, EuscanResult.objects.latest())