Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing vehicle to passenger log requirements #230

Merged
merged 4 commits into from
May 23, 2023

Conversation

syhwawa
Copy link
Contributor

@syhwawa syhwawa commented May 17, 2023

Fix missing vehicles error for passenger_log in the event handler when Elara fails to output the passenger log. Original PR #229

Screenshot 2023-05-17 at 12 17 09

Copy link
Contributor

@Theodore-Chatziioannou Theodore-Chatziioannou left a comment

Choose a reason for hiding this comment

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

Good catch

Copy link
Contributor

@KasiaKoz KasiaKoz left a comment

Choose a reason for hiding this comment

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

It would be good to see a test added that reproduces the error before it is fixed, and passing after the fix. I have a feeling this got missed out before (in this PR: #229) because there isn't much test coverage in this spot, so adding just that one extra test might help already with catching problems in the future.

@fredshone
Copy link
Contributor

nice catch @syhwawa - I'm not too bothered about a test - although kasia is right - we are also expecting to freeze dev on elara in any case

fredshone
fredshone previously approved these changes May 17, 2023
Copy link
Contributor

@fredshone fredshone left a comment

Choose a reason for hiding this comment

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

not sure what to make of this new test. Asserts something that can only ever be true, ie doesn't actually check behaviour.

IF you really want to test then the existing pattern in elara is to create the handler (eg here) (but note this requires using a bunch of fixtures) AND then test using the handler to process events (eg) AND then finalise.

You would need to add all these for the handler. Bit of a pain.

OR there is a cheaty way here that tries to "load all tools". Maybe check why this not working.

@syhwawa
Copy link
Contributor Author

syhwawa commented May 18, 2023

not sure what to make of this new test. Asserts something that can only ever be true, ie doesn't actually check behaviour.

IF you really want to test then the existing pattern in elara is to create the handler (eg here) (but note this requires using a bunch of fixtures) AND then test using the handler to process events (eg) AND then finalise.

You would need to add all these for the handler. Bit of a pain.

OR there is a cheaty way here that tries to "load all tools". Maybe check why this not working.

Thanks for the comment and suggestion @fredshone.

My initial idea is not acuatlly testing the handler in this unit test. I am wondering just to assert list == list for the requirements List from the each Class which having various inputs in the event_handler.py, to check if they match the added requirments list in this unit test. so it will pop up an error like below when we miss to add 'vehicles' in the requirments for VehiclePassengerLog Class when we add a new input for various Class.

./tests/test_2_event_handlers.py::test_class_requirements Failed: [undefined]AssertionError: Requirements do not match for class VehiclePassengerLog
assert ['events', 'transit_schedule'] == ['events', 'transit_schedule', 'vehicles']
  Right contains one more item: 'vehicles'
  Use -v to get more diff
test_config = <elara.config.Config object at 0x7fa245e46df0>

But I do forget the VehiclePassengerLog Class in the test again which a bit of embarrassing 🐼

@fredshone
Copy link
Contributor

I understand, but think that the this is not really a useful test because whatever shenanigans someone get's up to with the handlers in future - this test will never fail. Basically we are setting a = b in the module then testing a = b in the test. This can only fail if (i) we add some methods that mess with the requirments (not likely) or (ii) python breaks.

But if you insists i am happy for you to merge (I cannot swing so wildly from "don't need tests" to "that is not the correct test" :))

@syhwawa
Copy link
Contributor Author

syhwawa commented May 23, 2023

Thanks for the suggestions. @fredshone You're right, I see the examples tests you've provided make sense.

Considering the time and effort required for implementing these tests. I am a bit ashamed to decide to not extend the test coverage in this PR 😞.

Indeed, it needs the more extensive checks that you've pointed out, and maybe plan to revisit this as a part of a future task dedicated specifically to enhancing the test or move to develop a light post-process tool 🚀

@fredshone
Copy link
Contributor

fredshone commented May 23, 2023 via email

@syhwawa syhwawa merged commit 24e8a05 into main May 23, 2023
1 check passed
@syhwawa syhwawa deleted the fix-missing-vehicle-passenger-log branch May 23, 2023 18:15
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.

None yet

4 participants