dpytest icon indicating copy to clipboard operation
dpytest copied to clipboard

Tracking: Refactor and clean up architecture

Open CraftSpider opened this issue 5 years ago • 5 comments

  • [ ] Things should have their own files
    • [x] FakeState
    • [ ] FakeHttp
    • [x] FakeWebsocket
    • [x] Callbacks
    • [ ] Assertions
  • [x] More assertion functions, fewer boolean flags
  • [ ] Clarify: Backend vs Frontend state. One is 'discord', the other is 'us'
  • [ ] Complete missing functionality

This list may be edited / have associated issues linked to it as changes are made

CraftSpider avatar Jul 10 '20 20:07 CraftSpider

Please let me know if there is some way I can assist or if there is something you would like me to work on.

bravosierra99 avatar Jul 10 '20 22:07 bravosierra99

Some thoughts on 'more assertion functions': Given the gradual increase in flags, I think it may be worth it to go the way of libraries like junit or such, where you write asserts more like

runner.verify().message().text("foo").embed(embed).peek(True).assert()

runner.verify().nothing().assert()

runner.verify().embed(embed).no_text().assert()

This would be a bit of an undertaking, but would increase assert flexibility, improve readability, and decrease duplication. I don't really like every method having a ton of boolean flags on it, but having an exponential number of methods for all the options is also not a great solution, this solution takes a nice middle-ground.

CraftSpider avatar May 18 '21 02:05 CraftSpider

As much as that would be quite cool, since this is meant to work with pytest, I'd probs recommend using similar stuff to them (which I believe it currently is, but don't quote me) rather than junior for java. Also saves a breaking change from being made we which is never ideal if avoidable 😁

JayDwee avatar May 18 '21 06:05 JayDwee

Hi !

Yeah that would be great to decrease duplication, etc...

I know nothing about junit.

Maybe we could do this in pytest with some parametrized fixtures and parametrization stuff ? https://docs.pytest.org/en/6.2.x/parametrize.html#parametrize-basics https://docs.pytest.org/en/6.2.x/example/parametrize.html

(maybe there are plug-ins on PyPI too, to help writing the matrix of inputs / expected output, etc...)

Sergeileduc avatar May 18 '21 07:05 Sergeileduc

I opened a PR for my proposed change (#49). I believe the predicate/builder style is more in keeping with the pytest philosophy of explicit asserts, and that we will need to make a breaking change at some point to fix the current situation, so better to do it all at once then not have to again. I did look into fixtures and parameterization, but they really solve different classes of problem unfortunately. I would appreciate reviews, note that while the change is major on the backend, changing asserts was almost automatic (verify_message("FooBar") becomes verify().message().content("FooBar"), which I could have written a tool to change, and may do so if demand is high enough).

CraftSpider avatar Jun 03 '21 01:06 CraftSpider