Skip to content

Commit

Permalink
More tests of adding channels
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Jun 6, 2017
1 parent 429cf77 commit 945edd3
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions qcodes/tests/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ def test_channel_access_is_identical(self, value, channel):
# that currently does not support set.

def test_add_channel(self):
n_channels = len(self.instrument.channels)
name = 'foo'
channel = DummyChannel(self.instrument, 'Chan'+name, name)
self.instrument.channels.append(channel)
self.instrument.add_submodule(name, channel)

self.assertEqual(len(self.instrument.channels), 7)
self.assertEqual(len(self.instrument.channels), n_channels+1)

self.instrument.channels.lock()
# after locking the channels it's not possible to add any more channels
with self.assertRaises(AttributeError):
name = 'bar'
channel = DummyChannel(self.instrument, 'Chan' + name, name)
self.instrument.channels.append(channel)
self.instrument.add_submodule(name, channel)
self.assertEqual(len(self.instrument.channels), n_channels + 1)

def test_add_channels_from_generator(self):
n_channels = len(self.instrument.channels)
Expand All @@ -80,6 +81,30 @@ def test_add_channels_from_generator(self):

self.assertEqual(len(self.instrument.channels), n_channels + len(names))

def test_add_channels_from_tuple(self):
n_channels = len(self.instrument.channels)
names = ('foo', 'bar', 'foobar')
channels = tuple(DummyChannel(self.instrument, 'Chan'+name, name) for name in names)
self.instrument.channels.extend(channels)

self.assertEqual(len(self.instrument.channels), n_channels + len(names))

def test_insert_channel(self):
n_channels = len(self.instrument.channels)
name = 'foo'
channel = DummyChannel(self.instrument, 'Chan'+name, name)
self.instrument.channels.insert(1, channel)
self.instrument.add_submodule(name, channel)

self.assertEqual(len(self.instrument.channels), n_channels+1)
self.assertIs(self.instrument.channels[1], channel)
self.instrument.channels.lock()
# after locking the channels it's not possible to add any more channels
with self.assertRaises(AttributeError):
name = 'bar'
channel = DummyChannel(self.instrument, 'Chan' + name, name)
self.instrument.channels.insert(2, channel)
self.assertEqual(len(self.instrument.channels), n_channels + 1)

@given(setpoints=hst.lists(hst.floats(0, 300), min_size=4, max_size=4))
def test_combine_channels(self, setpoints):
Expand Down

0 comments on commit 945edd3

Please sign in to comment.