blob: 245ff1428fd95f23dbc8dd27c2d30e9bd76d36b6 [file] [log] [blame]
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for topology module."""
from __future__ import print_function
from chromite.cbuildbot import topology
from chromite.lib import fake_cidb
from chromite.lib import cros_test_lib
class ToplogyTest(cros_test_lib.TestCase):
"""Unit test of topology module."""
def setUp(self):
# Mutually isolate these tests and make them independent of
topology.topology = topology.LockedDefaultDict()
def testWithDB(self):
fake_db = fake_cidb.FakeCIDBConnection(fake_keyvals={'/foo': 'bar'})
self.assertEqual(topology.topology.get('/foo'), 'bar')
def testWithoutDB(self):
self.assertEqual(topology.topology.get('/foo'), None)
def testNotFetched(self):
with self.assertRaises(topology.LockedDictAccessException):