def test_transactional_set(connection): tree = NodeTree(connection, "DEV1234") with tree.set_transaction(): tree.demods[0].rate(22.0) connection.set.assert_called_once_with([("/dev1234/demods/0/rate", 22.0)]) with tree.set_transaction(): tree.demods[0].rate(22.0) tree.demods[0].phaseshift(1) connection.set.assert_called_with([("/dev1234/demods/0/rate", 22.0), ("/dev1234/demods/0/phaseshift", 1)]) with tree.set_transaction(): tree.demods[0].rate(22.0) tree.transaction.add("demods/0/phaseshift", 2) connection.set.assert_called_with([("/dev1234/demods/0/rate", 22.0), ("/dev1234/demods/0/phaseshift", 2)]) with tree.set_transaction(): tree.system.impedance.calib.user.data(b"Test Binary Data") connection.set.assert_called_with([ ("/dev1234/system/impedance/calib/user/data", b"Test Binary Data") ]) with pytest.raises(AttributeError) as e_info: tree.transaction.add("demods/0/phaseshift", 2) with pytest.raises(RuntimeError) as e_info: with tree.set_transaction(): with tree.set_transaction(): pass
def test_wildcard_node(connection): tree = NodeTree(connection, "DEV1234") wildcard_node = tree.demods["*"].rate assert wildcard_node.node_info.path == "/dev1234/demods/*/rate" with pytest.raises(KeyError) as e_info: wildcard_node.node_info.description # TODO add dummy Data to mock wildcard_node() wildcard_node(1) with tree.set_transaction(): wildcard_node = tree.demods["*"].rate(1) connection.get.return_value = None with pytest.raises(KeyError) as e_info: tree.hello["*"].rate() with pytest.raises(KeyError) as e_info: tree.hello["*"].rate(1)