Skip to content

Commit

Permalink
Merge pull request #279 from klauer/tst_does_linking_work
Browse files Browse the repository at this point in the history
TST: does linking work as expected?
  • Loading branch information
klauer authored Mar 10, 2022
2 parents 411820b + 1948285 commit baddfd5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pytmc/tests/test_xml_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,39 @@ def test_pv_linking_string():
assert lso_rec.fields["SIZV"] == 70


def test_pv_linking_struct():
struct = make_mock_twincatitem(
name='Main.my_dut',
data_type=make_mock_type('MY_DUT', is_complex_type=True),
pragma='pv: PREFIX; link: LINK:'
)

subitem1 = make_mock_twincatitem(
name='subitem1',
data_type=make_mock_type('INT'),
pragma='pv: ABCD; link: **ABCD.STAT'
)

subitem2 = make_mock_twincatitem(
name='subitem2',
data_type=make_mock_type('INT'),
pragma='pv: EFGH; link: OTHER_PV'
)

def walk(condition=None):
yield [struct, subitem1]
yield [struct, subitem2]

struct.walk = walk

pkg1, pkg2 = list(pragmas.record_packages_from_symbol(struct))
rec = pkg1.generate_output_record()
assert rec.fields['DOL'] == 'PREFIX:ABCD.STAT CPP MS'

rec = pkg2.generate_output_record()
assert rec.fields['DOL'] == 'LINK:OTHER_PV CPP MS'


def test_pv_linking_special():
struct = make_mock_twincatitem(
name='Main.array_base',
Expand Down

0 comments on commit baddfd5

Please sign in to comment.