diff --git a/euscanwww/djeuscan/tests/euscan_factory.py b/euscanwww/djeuscan/tests/euscan_factory.py index 8a36c69..2f72685 100644 --- a/euscanwww/djeuscan/tests/euscan_factory.py +++ b/euscanwww/djeuscan/tests/euscan_factory.py @@ -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): diff --git a/euscanwww/djeuscan/tests/test_charts.py b/euscanwww/djeuscan/tests/test_charts.py index 5d580dd..f4cb865 100644 --- a/euscanwww/djeuscan/tests/test_charts.py +++ b/euscanwww/djeuscan/tests/test_charts.py @@ -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) diff --git a/euscanwww/djeuscan/tests/test_models.py b/euscanwww/djeuscan/tests/test_models.py index a4fcbb1..4a320df 100644 --- a/euscanwww/djeuscan/tests/test_models.py +++ b/euscanwww/djeuscan/tests/test_models.py @@ -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())