Skip to content

Conversation

@jacomago
Copy link
Contributor

Adds a test for and fixes issue #92

@jacomago jacomago force-pushed the fix-infotag-loss-bug branch 3 times, most recently from e70c345 to 65cee1b Compare March 20, 2025 14:50
@jacomago
Copy link
Contributor Author

Current problem with this version is that owner is specified twice in cfstore, once from config, another from the ioc itself. Kind of makes sense, but means my check on the properties doesn't work in the merge_property_list. Need a cleverer check for the owner.

@jacomago
Copy link
Contributor Author

Realised should have all of the property names that receiver deals with anyway. The required property list. Just need to pass that as an extra argument

@jacomago jacomago force-pushed the fix-infotag-loss-bug branch from 65cee1b to 2c3d66d Compare March 24, 2025 07:20
@jacomago jacomago marked this pull request as ready for review March 24, 2025 10:55
Copy link
Contributor

@anderslindho anderslindho left a comment

Choose a reason for hiding this comment

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

Great find and fix!

Maybe separete the fix from the test that catches it in the git history. 🔧

It's a bit annoying how hardcoded much of the testing is here...

Comment on lines 22 to 24
if prop["name"] in properties_to_match:
if prop not in channel1["properties"]:
assert False, f"Property {prop} not found in channel {channel1['name']}"
Copy link
Contributor

Choose a reason for hiding this comment

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

If you skip the log message you can simplify this to an all or any check

log_thread.start()


class TestRemoveProperty:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a class here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh, why not

EXPECTED_DEFAULT_CHANNELS = 32


@pytest.fixture(scope="class")
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also do module scope and skip the class, since it's only two tests in this file

Comment on lines +398 to +411
def create_channel(name: str, owner: str, properties: list[dict[str, str]]):
return {
"name": name,
"owner": owner,
"properties": properties,
}


def create_property(owner: str, name: str, value: str):
return {
"name": name,
"owner": owner,
"value": value,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Extremely naïve question, but this looks a lot like you just want a dataclass, doesn't it? Or is that a "python is too old issue" or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More I thought adding it would be another refactor.

"""
newPropNames = [p["name"] for p in newProperties]
for oldProperty in oldProperties:
for oldProperty in channel["properties"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any chance that properties does not exist as a key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not here... I hope. I think raising exception is pretty suitable response if it happens. Which is the current behaviour.

@jacomago jacomago force-pushed the fix-infotag-loss-bug branch 2 times, most recently from ac31111 to 8de97cc Compare March 28, 2025 14:24
@jacomago jacomago force-pushed the fix-infotag-loss-bug branch 3 times, most recently from b1de169 to 4474792 Compare March 31, 2025 09:17
Bug can be reproduced manually as follows

1. Create recceiver with infotag (X) set to be updated in channelfinder.
2. Add IOC with PV with infotag X set to A
3. Channelfinder has PV with X=A
4. Reboot recceiver with  infotag X removed
5. Channelfinder has PV with X=A still even after IOC update

Or by

1. Create recceiver with infotag (X) set to be updated in channelfinder.
2. Add IOC with PV with infotag X set to A
3. Channelfinder has PV with X=A
4. Reboot IOC with PV with infotag X removed
5. Channelfinder has PV with X=A still
@jacomago jacomago force-pushed the fix-infotag-loss-bug branch 2 times, most recently from 0167001 to 44539ec Compare April 1, 2025 08:31
jacomago added 4 commits April 1, 2025 13:13
To find source of problem
Essentially when merging property lists, should only take the old data when setting the channel to be inactive. Otherwise only the new data owned by the recceiver is relevant
@jacomago jacomago force-pushed the fix-infotag-loss-bug branch from 44539ec to d17610d Compare April 1, 2025 11:13
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@jacomago jacomago merged commit 7e2d11c into ChannelFinder:master Apr 1, 2025
65 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants