Files
odoo_source/addons/web/test/test_serving_base.py
T
Xavier Morel 532e60a007 [FIX] dependencies handling in modules listing of web client
* Correctly fetch dependencies from server
* Switch topological sort to a more formal algorithm (and test it)

lp bug: https://launchpad.net/bugs/947161 fixed

bzr revid: xmo@openerp.com-20120306142010-zflycbrj4aq41mv3
2012-03-06 15:20:10 +01:00

35 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
import random
import unittest2
from ..controllers.main import topological_sort
def sample(population):
return random.sample(
population,
random.randint(0, min(len(population), 5)))
class TestModulesLoading(unittest2.TestCase):
def setUp(self):
self.mods = map(str, range(1000))
def test_topological_sort(self):
random.shuffle(self.mods)
modules = [
(k, sample(self.mods[:i]))
for i, k in enumerate(self.mods)]
random.shuffle(modules)
ms = dict(modules)
seen = set()
sorted_modules = topological_sort(ms)
for module in sorted_modules:
deps = ms[module]
self.assertGreaterEqual(
seen, set(deps),
'Module %s (index %d), ' \
'missing dependencies %s from loaded modules %s' % (
module, sorted_modules.index(module), deps, seen
))
seen.add(module)