diff --git a/euscanwww/djeuscan/tests/euscan_factory.py b/euscanwww/djeuscan/tests/euscan_factory.py index 476b9d1..8a36c69 100644 --- a/euscanwww/djeuscan/tests/euscan_factory.py +++ b/euscanwww/djeuscan/tests/euscan_factory.py @@ -1,5 +1,13 @@ +import random +from string import letters import factory -from djeuscan.models import Herd, Maintainer, Package, Version +from datetime import datetime + +from djeuscan.models import Herd, Maintainer, Package, Version, EuscanResult + + +def random_string(length=10): + return "".join([random.choice(letters) for _ in range(length)]) class HerdFactory(factory.Factory): @@ -19,8 +27,8 @@ class MaintainerFactory(factory.Factory): class PackageFactory(factory.Factory): FACTORY_FOR = Package - category = "Test Category" - name = "Test Package" + category = factory.LazyAttribute(lambda a: random_string()) + name = factory.LazyAttribute(lambda a: random_string()) description = "This is a test package" homepage = "http://testpackage.com" @@ -36,3 +44,11 @@ class VersionFactory(factory.Factory): overlay = "gentoo" urls = "http://packageurl.com" alive = True + + +class EuscanResultFactory(factory.Factory): + FACTORY_FOR = EuscanResult + + package = factory.LazyAttribute(lambda a: PackageFactory()) + datetime = datetime.now() + result = "this is the result" diff --git a/euscanwww/djeuscan/tests/test_charts.py b/euscanwww/djeuscan/tests/test_charts.py index 5d19259..5d580dd 100644 --- a/euscanwww/djeuscan/tests/test_charts.py +++ b/euscanwww/djeuscan/tests/test_charts.py @@ -3,7 +3,7 @@ from euscanwww.djeuscan.tests import SystemTestCase class ChartTests(SystemTestCase): """ - Test main pages + Test charts """ def test_statistics(self): @@ -13,3 +13,49 @@ class ChartTests(SystemTestCase): def test_pie_versions(self): response = self.get("chart", chart="pie-versions") self.assertEqual(response.status_code, 200) + + def test_pie_packages(self): + response = self.get("chart", chart="pie-packages") + self.assertEqual(response.status_code, 200) + + def test_packages(self): + response = self.get("chart", chart="packages") + self.assertEqual(response.status_code, 200) + + def test_packages_options(self): + response = self.get("chart", chart="packages-small") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="packages-weekly") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="packages-monthly") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="packages-yearly") + self.assertEqual(response.status_code, 200) + + def test_packages_option_incorrect(self): + response = self.get("chart", chart="packages-trololol") + self.assertEqual(response.status_code, 404) + + def test_versions(self): + response = self.get("chart", chart="versions") + self.assertEqual(response.status_code, 200) + + def test_versions_options(self): + response = self.get("chart", chart="versions-small") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="versions-weekly") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="versions-monthly") + self.assertEqual(response.status_code, 200) + + response = self.get("chart", chart="versions-yearly") + self.assertEqual(response.status_code, 200) + + def test_versions_option_incorrect(self): + response = self.get("chart", chart="versions-trololol") + self.assertEqual(response.status_code, 404) diff --git a/euscanwww/djeuscan/tests/test_models.py b/euscanwww/djeuscan/tests/test_models.py index 5c9dd26..a4fcbb1 100644 --- a/euscanwww/djeuscan/tests/test_models.py +++ b/euscanwww/djeuscan/tests/test_models.py @@ -2,10 +2,14 @@ tests for models """ +from datetime import datetime + from django.utils import unittest from django.db import IntegrityError -from djeuscan.tests.euscan_factory import VersionFactory, PackageFactory +from djeuscan.models import EuscanResult +from djeuscan.tests.euscan_factory import VersionFactory, PackageFactory, \ + EuscanResultFactory class VersionModelTests(unittest.TestCase): @@ -20,3 +24,18 @@ class VersionModelTests(unittest.TestCase): with self.assertRaises(IntegrityError): VersionFactory.create(package=package) + + +class PackageModelTests(unittest.TestCase): + def test_homepages(self): + homepage = "http://gentoo.org http://mypackage.com" + package = PackageFactory.build(homepage=homepage) + self.assertEqual(package.homepages, + ["http://gentoo.org", "http://mypackage.com"]) + + +class EuscanResultModelTests(unittest.TestCase): + def test_lastest(self): + result1 = EuscanResultFactory.create(datetime=datetime(2012, 04, 01)) + result2 = EuscanResultFactory.create(datetime=datetime(2012, 01, 01)) + self.assertEqual(result1, EuscanResult.objects.latest()) diff --git a/euscanwww/euscanwww/templates/404.html b/euscanwww/euscanwww/templates/404.html new file mode 100644 index 0000000..03332b4 --- /dev/null +++ b/euscanwww/euscanwww/templates/404.html @@ -0,0 +1 @@ +