Skip to content
Merged
4 changes: 4 additions & 0 deletions generated/nifake/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Session(object):
'''
An attribute of type string with read/write access.
'''
read_write_integer = AttributeViInt32(1000004)
'''
An attribute of type integer with read/write access.
'''

def __init__(self, resource_name, id_query=False, reset_device=False, options_string=""):
self.library = library_singleton.get()
Expand Down
17 changes: 17 additions & 0 deletions generated/nifake/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,23 @@ def test_init_with_options_nondefault(self):
assert(session.vi == SESSION_NUM_FOR_TEST)
self.patched_library.niFake_InitWithOptions.assert_called_once_with(b'FakeDevice', True, True, b'Some string', ANY)

def test_get_vi_int32_attribute(self):
self.patched_library.niFake_GetAttributeViInt32.side_effect = self.side_effects_helper.niFake_GetAttributeViInt32
test_number = 3
self.side_effects_helper['GetAttributeViInt32']['attributeValue'] = test_number
with nifake.Session('dev1') as session:
attr_int = session.read_write_integer
assert(attr_int == test_number)
self.patched_library.niFake_GetAttributeViInt32.assert_called_once_with(SESSION_NUM_FOR_TEST, b'', 1000004, ANY)

def test_set_vi_int32_attribute(self):
self.patched_library.niFake_SetAttributeViInt32.side_effect = self.side_effects_helper.niFake_SetAttributeViInt32
attribute_id = 1000004
test_number = 1
with nifake.Session('dev1') as session:
session.read_write_integer = test_number
self.patched_library.niFake_SetAttributeViInt32.assert_called_once_with(SESSION_NUM_FOR_TEST, b'', attribute_id, test_number)

def test_read(self):
test_maximum_time = 10
test_reading = 5
Expand Down
12 changes: 12 additions & 0 deletions src/nifake/metadata/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@
'description':'An attribute of type Color with read/write access.',
},
},
1000004: {
'access': 'read-write',
'channel_based': 'False',
'enum': None,
'lv_property': 'Fake attributes:Read Write Int',
'name': 'READ_WRITE_INTEGER',
'resettable': 'No',
'type': 'ViInt32',
'documentation': {
'description':'An attribute of type integer with read/write access.',
},
},
}
17 changes: 17 additions & 0 deletions src/nifake/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,23 @@ def test_init_with_options_nondefault(self):
assert(session.vi == SESSION_NUM_FOR_TEST)
self.patched_library.niFake_InitWithOptions.assert_called_once_with(b'FakeDevice', True, True, b'Some string', ANY)

def test_get_vi_int32_attribute(self):
self.patched_library.niFake_GetAttributeViInt32.side_effect = self.side_effects_helper.niFake_GetAttributeViInt32
test_number = 3
self.side_effects_helper['GetAttributeViInt32']['attributeValue'] = test_number
with nifake.Session('dev1') as session:
attr_int = session.read_write_integer
assert(attr_int == test_number)
self.patched_library.niFake_GetAttributeViInt32.assert_called_once_with(SESSION_NUM_FOR_TEST, b'', 1000004, ANY)

def test_set_vi_int32_attribute(self):
self.patched_library.niFake_SetAttributeViInt32.side_effect = self.side_effects_helper.niFake_SetAttributeViInt32
attribute_id = 1000004
test_number = 1
with nifake.Session('dev1') as session:
session.read_write_integer = test_number
self.patched_library.niFake_SetAttributeViInt32.assert_called_once_with(SESSION_NUM_FOR_TEST, b'', attribute_id, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you didn't use test_number here?


def test_read(self):
test_maximum_time = 10
test_reading = 5
Expand Down