tests refactoring and some fixes
This commit is contained in:
parent
9a39328e3b
commit
d3676250ab
@ -143,24 +143,30 @@ def pie_packages(**kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def rrd_path(name):
|
def rrd_path(name):
|
||||||
return str(os.path.join(settings.RRD_ROOT, name + '.rrd'))
|
res = str(os.path.join(settings.RRD_ROOT, name))
|
||||||
|
if res.endswith(".rrd"):
|
||||||
|
return res
|
||||||
|
else:
|
||||||
|
return res + ".rrd"
|
||||||
|
|
||||||
|
|
||||||
def rrd_create(name, start):
|
def rrd_create(name, start=None):
|
||||||
|
if start is None:
|
||||||
|
start = int(time.time())
|
||||||
|
|
||||||
path = rrd_path(name)
|
path = rrd_path(name)
|
||||||
if os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return
|
rrdtool.create(path, '--step', '86400',
|
||||||
rrdtool.create(path, '--step', '86400',
|
'--start', '%s' % int(start - 10),
|
||||||
'--start', '%s' % int(start - 10),
|
'DS:n_packages_gentoo:GAUGE:4294967295:0:U',
|
||||||
'DS:n_packages_gentoo:GAUGE:4294967295:0:U',
|
'DS:n_packages_overlay:GAUGE:4294967295:0:U',
|
||||||
'DS:n_packages_overlay:GAUGE:4294967295:0:U',
|
'DS:n_packages_outdated:GAUGE:4294967295:0:U',
|
||||||
'DS:n_packages_outdated:GAUGE:4294967295:0:U',
|
'DS:n_versions_gentoo:GAUGE:4294967295:0:U',
|
||||||
'DS:n_versions_gentoo:GAUGE:4294967295:0:U',
|
'DS:n_versions_overlay:GAUGE:4294967295:0:U',
|
||||||
'DS:n_versions_overlay:GAUGE:4294967295:0:U',
|
'DS:n_versions_upstream:GAUGE:4294967295:0:U',
|
||||||
'DS:n_versions_upstream:GAUGE:4294967295:0:U',
|
'RRA:AVERAGE:0.5:1:100',
|
||||||
'RRA:AVERAGE:0.5:1:100',
|
'RRA:AVERAGE:0.5:5:200',
|
||||||
'RRA:AVERAGE:0.5:5:200',
|
'RRA:AVERAGE:0.5:10:200')
|
||||||
'RRA:AVERAGE:0.5:10:200')
|
|
||||||
|
|
||||||
|
|
||||||
def rrd_update(name, datetime, values):
|
def rrd_update(name, datetime, values):
|
||||||
@ -178,7 +184,8 @@ def rrd_update(name, datetime, values):
|
|||||||
"""
|
"""
|
||||||
[-s|--start time] [-e|--end time] [-S|--step seconds]
|
[-s|--start time] [-e|--end time] [-S|--step seconds]
|
||||||
[-t|--title string] [-v|--vertical-label string]
|
[-t|--title string] [-v|--vertical-label string]
|
||||||
[-w|--width pixels] [-h|--height pixels] [-j|--only-graph] [-D|--full-size-mode][-u|--upper-limit value] [-l|--lower-limit value]
|
[-w|--width pixels] [-h|--height pixels] [-j|--only-graph]
|
||||||
|
[-D|--full-size-mode][-u|--upper-limit value] [-l|--lower-limit value]
|
||||||
[-u|--upper-limit value] [-l|--lower-limit value] [-r|--rigid]
|
[-u|--upper-limit value] [-l|--lower-limit value] [-r|--rigid]
|
||||||
[-A|--alt-autoscale]
|
[-A|--alt-autoscale]
|
||||||
[-M|--alt-autoscale-max]
|
[-M|--alt-autoscale-max]
|
||||||
@ -198,7 +205,10 @@ def cached_rrd_chart(f):
|
|||||||
kwds['title'] = '%s (%s)' % (f.func_name, kwds['period'])
|
kwds['title'] = '%s (%s)' % (f.func_name, kwds['period'])
|
||||||
kwds['steps'] = kwds['period']
|
kwds['steps'] = kwds['period']
|
||||||
kwds['vertical-label'] = f.func_name
|
kwds['vertical-label'] = f.func_name
|
||||||
|
|
||||||
kwds['rrd'] = rrd_path(rrd_name(**kwds))
|
kwds['rrd'] = rrd_path(rrd_name(**kwds))
|
||||||
|
rrd_create(kwds['rrd']) # create the rrd file if it's not present
|
||||||
|
|
||||||
kwds['path'] = path
|
kwds['path'] = path
|
||||||
|
|
||||||
kwds['end'] = 'now'
|
kwds['end'] = 'now'
|
||||||
@ -229,8 +239,11 @@ def cached_rrd_chart(f):
|
|||||||
|
|
||||||
@cached_rrd_chart
|
@cached_rrd_chart
|
||||||
def packages(**kwargs):
|
def packages(**kwargs):
|
||||||
|
path = str(kwargs['path'])
|
||||||
|
rrd = kwargs['rrd']
|
||||||
|
|
||||||
rrdtool.graph(
|
rrdtool.graph(
|
||||||
str(kwargs['path']),
|
path,
|
||||||
'--imgformat', 'PNG',
|
'--imgformat', 'PNG',
|
||||||
'--width', kwargs['width'],
|
'--width', kwargs['width'],
|
||||||
'--height', kwargs['height'],
|
'--height', kwargs['height'],
|
||||||
@ -243,11 +256,9 @@ def packages(**kwargs):
|
|||||||
'--vertical-label', kwargs['vertical-label'],
|
'--vertical-label', kwargs['vertical-label'],
|
||||||
'--title', kwargs['title'],
|
'--title', kwargs['title'],
|
||||||
'--lower-limit', '0',
|
'--lower-limit', '0',
|
||||||
'DEF:n_packages_gentoo=%s:n_packages_gentoo:AVERAGE' % (kwargs['rrd']),
|
'DEF:n_packages_gentoo=%s:n_packages_gentoo:AVERAGE' % rrd,
|
||||||
'DEF:n_packages_overlay=%s:n_packages_overlay:AVERAGE' % \
|
'DEF:n_packages_overlay=%s:n_packages_overlay:AVERAGE' % rrd,
|
||||||
(kwargs['rrd']),
|
'DEF:n_packages_outdated=%s:n_packages_outdated:AVERAGE' % rrd,
|
||||||
'DEF:n_packages_outdated=%s:n_packages_outdated:AVERAGE' % \
|
|
||||||
(kwargs['rrd']),
|
|
||||||
'LINE1.25:n_packages_gentoo#008000:Gentoo',
|
'LINE1.25:n_packages_gentoo#008000:Gentoo',
|
||||||
'LINE1.25:n_packages_overlay#0B17FD:Overlay',
|
'LINE1.25:n_packages_overlay#0B17FD:Overlay',
|
||||||
'LINE1.25:n_packages_outdated#FF0000:Outdated'
|
'LINE1.25:n_packages_outdated#FF0000:Outdated'
|
||||||
@ -256,8 +267,11 @@ def packages(**kwargs):
|
|||||||
|
|
||||||
@cached_rrd_chart
|
@cached_rrd_chart
|
||||||
def versions(**kwargs):
|
def versions(**kwargs):
|
||||||
|
path = str(kwargs['path'])
|
||||||
|
rrd = kwargs['rrd']
|
||||||
|
|
||||||
rrdtool.graph(
|
rrdtool.graph(
|
||||||
str(kwargs['path']),
|
path,
|
||||||
'--imgformat', 'PNG',
|
'--imgformat', 'PNG',
|
||||||
'--width', kwargs['width'],
|
'--width', kwargs['width'],
|
||||||
'--height', kwargs['height'],
|
'--height', kwargs['height'],
|
||||||
@ -269,11 +283,9 @@ def versions(**kwargs):
|
|||||||
'--vertical-label', kwargs['vertical-label'],
|
'--vertical-label', kwargs['vertical-label'],
|
||||||
'--title', kwargs['title'],
|
'--title', kwargs['title'],
|
||||||
'--lower-limit', '0',
|
'--lower-limit', '0',
|
||||||
'DEF:n_versions_gentoo=%s:n_versions_gentoo:AVERAGE' % (kwargs['rrd']),
|
'DEF:n_versions_gentoo=%s:n_versions_gentoo:AVERAGE' % rrd,
|
||||||
'DEF:n_versions_overlay=%s:n_versions_overlay:AVERAGE' % \
|
'DEF:n_versions_overlay=%s:n_versions_overlay:AVERAGE' % rrd,
|
||||||
(kwargs['rrd']),
|
'DEF:n_versions_outdated=%s:n_versions_upstream:AVERAGE' % rrd,
|
||||||
'DEF:n_versions_outdated=%s:n_versions_upstream:AVERAGE' % \
|
|
||||||
(kwargs['rrd']),
|
|
||||||
'LINE1.25:n_versions_gentoo#008000:Gentoo',
|
'LINE1.25:n_versions_gentoo#008000:Gentoo',
|
||||||
'LINE1.25:n_versions_overlay#0B17FD:Overlay',
|
'LINE1.25:n_versions_overlay#0B17FD:Overlay',
|
||||||
'LINE1.25:n_versions_outdated#FF0000:Outdated'
|
'LINE1.25:n_versions_outdated#FF0000:Outdated'
|
||||||
|
@ -114,7 +114,7 @@ class PackageManager(models.Manager, PackageMixin):
|
|||||||
|
|
||||||
class VersionLogMixin(object):
|
class VersionLogMixin(object):
|
||||||
def for_package(self, package, order=False):
|
def for_package(self, package, order=False):
|
||||||
res = filter(package=package)
|
res = self.filter(package=package)
|
||||||
if order:
|
if order:
|
||||||
res = res.order_by('-id')
|
res = res.order_by('-id')
|
||||||
return res
|
return res
|
||||||
|
@ -8,74 +8,95 @@ class ChartTests(SystemTestCase):
|
|||||||
Test charts
|
Test charts
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
url = "chart"
|
||||||
|
args = []
|
||||||
|
kwargs = {}
|
||||||
|
|
||||||
def test_statistics(self):
|
def test_statistics(self):
|
||||||
response = self.get("statistics")
|
response = self.get("statistics")
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_pie_versions(self):
|
def test_pie_versions(self):
|
||||||
response = self.get("chart", chart="pie-versions")
|
response = self.get(self.url, chart="pie-versions",
|
||||||
|
*self.args, **self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_pie_packages(self):
|
def test_pie_packages(self):
|
||||||
response = self.get("chart", chart="pie-packages")
|
response = self.get(self.url, chart="pie-packages", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_packages(self):
|
def test_packages(self):
|
||||||
response = self.get("chart", chart="packages")
|
response = self.get(self.url, chart="packages", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_packages_options(self):
|
def test_packages_options(self):
|
||||||
response = self.get("chart", chart="packages-small")
|
response = self.get(self.url, chart="packages-small", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="packages-weekly")
|
response = self.get(self.url, chart="packages-weekly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="packages-monthly")
|
response = self.get(self.url, chart="packages-monthly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="packages-yearly")
|
response = self.get(self.url, chart="packages-yearly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_packages_option_incorrect(self):
|
def test_packages_option_incorrect(self):
|
||||||
response = self.get("chart", chart="packages-trololol")
|
response = self.get(self.url, chart="packages-trololol", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_versions(self):
|
def test_versions(self):
|
||||||
response = self.get("chart", chart="versions")
|
response = self.get(self.url, chart="versions", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_versions_options(self):
|
def test_versions_options(self):
|
||||||
response = self.get("chart", chart="versions-small")
|
response = self.get(self.url, chart="versions-small", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="versions-weekly")
|
response = self.get(self.url, chart="versions-weekly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="versions-monthly")
|
response = self.get(self.url, chart="versions-monthly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
response = self.get("chart", chart="versions-yearly")
|
response = self.get(self.url, chart="versions-yearly", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_versions_option_incorrect(self):
|
def test_versions_option_incorrect(self):
|
||||||
response = self.get("chart", chart="versions-trololol")
|
response = self.get(self.url, chart="versions-trololol", *self.args,
|
||||||
|
**self.kwargs)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_herd(self):
|
|
||||||
a_herd = HerdFactory.create()
|
|
||||||
response = self.get("chart_herd", chart="pie-packages",
|
|
||||||
herd=a_herd.herd)
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
def test_maintainer(self):
|
class CategoryChartTests(ChartTests):
|
||||||
a_maintainer = MaintainerFactory.create()
|
def setUp(self):
|
||||||
response = self.get("chart_maintainer", chart="pie-packages",
|
super(CategoryChartTests, self).setUp()
|
||||||
maintainer_id=a_maintainer.pk)
|
self.url = "chart_category"
|
||||||
self.assertEqual(response.status_code, 200)
|
self.kwargs = {"category": PackageFactory.create().category}
|
||||||
|
|
||||||
def test_category(self):
|
|
||||||
a_category = PackageFactory.create().category
|
class HerdChartTests(ChartTests):
|
||||||
response = self.get("chart_category", chart="pie-packages",
|
def setUp(self):
|
||||||
category=a_category)
|
super(HerdChartTests, self).setUp()
|
||||||
self.assertEqual(response.status_code, 200)
|
self.url = "chart_herd"
|
||||||
|
self.kwargs = {"herd": HerdFactory.create().herd}
|
||||||
|
|
||||||
|
|
||||||
|
class MaintainerChartTests(ChartTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(MaintainerChartTests, self).setUp()
|
||||||
|
self.url = "chart_maintainer"
|
||||||
|
self.kwargs = {"maintainer_id": MaintainerFactory.create().id}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import StringIO
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
|
|
||||||
from djeuscan.tests import SystemTestCase
|
from djeuscan.tests import SystemTestCase
|
||||||
@ -5,7 +6,7 @@ from djeuscan.tests.euscan_factory import PackageFactory, HerdFactory, \
|
|||||||
MaintainerFactory, VersionFactory, random_string
|
MaintainerFactory, VersionFactory, random_string
|
||||||
|
|
||||||
|
|
||||||
class NavigationTest(SystemTestCase):
|
class PagesTest(SystemTestCase):
|
||||||
"""
|
"""
|
||||||
Test main pages
|
Test main pages
|
||||||
"""
|
"""
|
||||||
@ -17,80 +18,119 @@ class NavigationTest(SystemTestCase):
|
|||||||
response = self.get("index")
|
response = self.get("index")
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_categories(self):
|
|
||||||
categories = [PackageFactory.create().category
|
|
||||||
for _ in range(10)]
|
|
||||||
|
|
||||||
response = self.get("categories")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content)
|
|
||||||
rows = soup.findAll("tr")
|
|
||||||
|
|
||||||
self.assertEqual(len(rows), len(categories))
|
|
||||||
|
|
||||||
for category in categories:
|
|
||||||
self.assertTrue(category in response.content)
|
|
||||||
|
|
||||||
def test_herds(self):
|
|
||||||
herds = [HerdFactory.create() for _ in range(10)]
|
|
||||||
packages = []
|
|
||||||
for i in range(0, 10, 2):
|
|
||||||
p = PackageFactory.create()
|
|
||||||
p.herds.add(herds[i])
|
|
||||||
p.herds.add(herds[i + 1])
|
|
||||||
packages.append(p)
|
|
||||||
|
|
||||||
response = self.get("herds")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content)
|
|
||||||
rows = soup.findAll("tr")
|
|
||||||
|
|
||||||
self.assertEqual(len(rows), len(herds))
|
|
||||||
|
|
||||||
for herd in herds:
|
|
||||||
self.assertTrue(herd.herd in response.content)
|
|
||||||
|
|
||||||
def test_maintainers(self):
|
|
||||||
maintainers = [MaintainerFactory.create() for _ in range(10)]
|
|
||||||
packages = []
|
|
||||||
for i in range(0, 10, 2):
|
|
||||||
p = PackageFactory.create()
|
|
||||||
p.maintainers.add(maintainers[i])
|
|
||||||
p.maintainers.add(maintainers[i + 1])
|
|
||||||
packages.append(p)
|
|
||||||
|
|
||||||
response = self.get("maintainers")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content)
|
|
||||||
rows = soup.findAll("tr")
|
|
||||||
|
|
||||||
self.assertEqual(len(rows), len(maintainers))
|
|
||||||
|
|
||||||
for maintainer in maintainers:
|
|
||||||
self.assertTrue(maintainer.name in response.content)
|
|
||||||
|
|
||||||
def test_overlays(self):
|
|
||||||
overlays = [random_string() for _ in range(3)]
|
|
||||||
|
|
||||||
for _ in range(3):
|
|
||||||
package = PackageFactory.create()
|
|
||||||
for overlay in overlays:
|
|
||||||
VersionFactory.create(package=package, overlay=overlay)
|
|
||||||
|
|
||||||
response = self.get("overlays")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(response.content)
|
|
||||||
rows = soup.findAll("tr")
|
|
||||||
|
|
||||||
self.assertEqual(len(rows), len(overlays))
|
|
||||||
|
|
||||||
for overlay in overlays:
|
|
||||||
self.assertTrue(overlay in response.content)
|
|
||||||
|
|
||||||
def test_world(self):
|
def test_world(self):
|
||||||
response = self.get("world")
|
response = self.get("world")
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_about(self):
|
||||||
|
response = self.get("about")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
|
class SectionTests(SystemTestCase):
|
||||||
|
def _check_table(self, response, items, attr=None):
|
||||||
|
soup = BeautifulSoup(response.content)
|
||||||
|
rows = soup.findAll("tr")
|
||||||
|
|
||||||
|
self.assertEqual(len(rows), len(items))
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
if attr:
|
||||||
|
item_str = getattr(item, attr)
|
||||||
|
else:
|
||||||
|
item_str = item
|
||||||
|
self.assertTrue(item_str in response.content)
|
||||||
|
|
||||||
|
|
||||||
|
class CategoriesTests(SectionTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(CategoriesTests, self).setUp()
|
||||||
|
self.categories = [PackageFactory.create().category
|
||||||
|
for _ in range(10)]
|
||||||
|
|
||||||
|
def test_categories(self):
|
||||||
|
response = self.get("categories")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.categories)
|
||||||
|
|
||||||
|
|
||||||
|
class HerdsTests(SectionTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(HerdsTests, self).setUp()
|
||||||
|
self.herds = [HerdFactory.create() for _ in range(10)]
|
||||||
|
self.packages = []
|
||||||
|
for i in range(0, 10, 2):
|
||||||
|
p = PackageFactory.create()
|
||||||
|
p.herds.add(self.herds[i])
|
||||||
|
p.herds.add(self.herds[i + 1])
|
||||||
|
self.packages.append(p)
|
||||||
|
|
||||||
|
def test_herds(self):
|
||||||
|
response = self.get("herds")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.herds, attr="herd")
|
||||||
|
|
||||||
|
|
||||||
|
class MaintainersTests(SectionTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(MaintainersTests, self).setUp()
|
||||||
|
self.maintainers = [MaintainerFactory.create() for _ in range(10)]
|
||||||
|
self.packages = []
|
||||||
|
for i in range(0, 10, 2):
|
||||||
|
p = PackageFactory.create()
|
||||||
|
p.maintainers.add(self.maintainers[i])
|
||||||
|
p.maintainers.add(self.maintainers[i + 1])
|
||||||
|
self.packages.append(p)
|
||||||
|
|
||||||
|
def test_maintainers(self):
|
||||||
|
response = self.get("maintainers")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.maintainers, attr="name")
|
||||||
|
|
||||||
|
|
||||||
|
class OverlayTests(SectionTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(OverlayTests, self).setUp()
|
||||||
|
self.overlays = [random_string() for _ in range(3)]
|
||||||
|
|
||||||
|
for _ in range(3):
|
||||||
|
self.package = PackageFactory.create()
|
||||||
|
for overlay in self.overlays:
|
||||||
|
VersionFactory.create(package=self.package,
|
||||||
|
overlay=overlay)
|
||||||
|
|
||||||
|
def test_overlays(self):
|
||||||
|
response = self.get("overlays")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.overlays)
|
||||||
|
|
||||||
|
|
||||||
|
class WorldScanTests(SectionTests):
|
||||||
|
def setUp(self):
|
||||||
|
super(WorldScanTests, self).setUp()
|
||||||
|
for _ in range(3):
|
||||||
|
PackageFactory.create()
|
||||||
|
self.packages = [PackageFactory.create().name for _ in range(3)]
|
||||||
|
|
||||||
|
def test_world_scan_packages(self):
|
||||||
|
response = self.post("world_scan",
|
||||||
|
data={"packages": "\n".join(self.packages)})
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.packages)
|
||||||
|
|
||||||
|
def test_world_scan_world(self):
|
||||||
|
world_file = StringIO.StringIO()
|
||||||
|
world_file.write("\n".join(self.packages))
|
||||||
|
world_file.name = "world"
|
||||||
|
world_file.read = world_file.getvalue
|
||||||
|
|
||||||
|
response = self.post("world_scan", data={"world": world_file})
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
self._check_table(response, self.packages)
|
||||||
|
@ -59,7 +59,7 @@ def herds(request):
|
|||||||
@render_to('euscan/herd.html')
|
@render_to('euscan/herd.html')
|
||||||
def herd(request, herd):
|
def herd(request, herd):
|
||||||
herd = get_object_or_404(Herd, herd=herd)
|
herd = get_object_or_404(Herd, herd=herd)
|
||||||
packages = Package.for_herd(herd, last_versions=True)
|
packages = Package.objects.for_herd(herd, last_versions=True)
|
||||||
return {'herd': herd, 'packages': packages}
|
return {'herd': herd, 'packages': packages}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ EUSCAN_ROOT = os.path.join(dirname(dirname(abspath(__file__))), "euscanwww")
|
|||||||
|
|
||||||
settings.configure(
|
settings.configure(
|
||||||
DATABASES={
|
DATABASES={
|
||||||
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory;'}
|
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}
|
||||||
},
|
},
|
||||||
INSTALLED_APPS=['euscanwww.euscanwww', 'djeuscan'],
|
INSTALLED_APPS=['euscanwww.euscanwww', 'djeuscan'],
|
||||||
ROOT_URLCONF='euscanwww.euscanwww.urls',
|
ROOT_URLCONF='euscanwww.euscanwww.urls',
|
||||||
|
Loading…
Reference in New Issue
Block a user