Add unit tests for include_links in get_services()

Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
d11wtq 2014-06-08 10:58:13 +00:00 committed by Chris Corbyn
parent c0231bdb70
commit 5d92f12f8e
1 changed files with 41 additions and 0 deletions

View File

@ -93,3 +93,44 @@ class ProjectTest(unittest.TestCase):
)
project = Project('test', [web, console], None)
self.assertEqual(project.get_services(['console']), [console])
def test_get_services_with_include_links(self):
db = Service(
project='figtest',
name='db',
)
web = Service(
project='figtest',
name='web',
links=[(db, 'database')]
)
cache = Service(
project='figtest',
name='cache'
)
console = Service(
project='figtest',
name='console',
links=[(web, 'web')]
)
project = Project('test', [web, db, cache, console], None)
self.assertEqual(
project.get_services(['console'], include_links=True),
[db, web, console]
)
def test_get_services_removes_duplicates_following_links(self):
db = Service(
project='figtest',
name='db',
)
web = Service(
project='figtest',
name='web',
links=[(db, 'database')]
)
project = Project('test', [web, db], None)
self.assertEqual(
project.get_services(['web', 'db'], include_links=True),
[db, web]
)