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

Sytest: Add 10apidoc/36room-levels tests #545

Merged
merged 3 commits into from
Nov 14, 2022

Conversation

ShadowJonathan
Copy link
Contributor

This adds three sytests:

  • ./tests/10apidoc/36room-levels.pl:test "GET /rooms/:room_id/state/m.room.power_levels can fetch levels",
  • ./tests/10apidoc/36room-levels.pl:test "PUT /rooms/:room_id/state/m.room.power_levels can set levels",
  • ./tests/10apidoc/36room-levels.pl:test "PUT power_levels should not explode if the old power levels were empty",

This skips a test called "Both GET and PUT work" because its sole existence in sytest appears to be to prove the ability to set and get powerlevels, for other test's requirements.

@ShadowJonathan ShadowJonathan requested review from a team as code owners October 29, 2022 12:19
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

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

some of these don't seem like faithful translations — maybe that's fine, but I was a bit surprised.

However I think some checks have been dropped and I would like to see them matched or have some explanation for why they were dropped.

That said, thanks for doing this!

Would you like to open a corresponding PR in SyTest to remove the SyTests? We've been saying we should remove them at the same time and adding them to Complement, because otherwise the SyTest gets updated and they fall out of sync and need translating again. Also, no sense testing things twice...

tests/csapi/power_levels_test.go Show resolved Hide resolved
tests/csapi/power_levels_test.go Show resolved Hide resolved
tests/csapi/power_levels_test.go Show resolved Hide resolved
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

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

minor points, other than that I think we should have the SyTest PR lined up to remove the SyTest before merging this

tests/csapi/power_levels_test.go Show resolved Hide resolved
Comment on lines +63 to +67
// note: before v10 we technically cannot assume that powerlevel integers are json numbers,
// as they can be both strings and numbers.
// However, for this test, we control the test environment,
// and we will assume the server is sane and give us powerlevels as numbers,
// and if it doesn't, that's an offense worthy of a frown.
Copy link
Contributor

Choose a reason for hiding this comment

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

meh, I think anyone would be happy to agree that a server that creates stringy power levels itself (not just accepting them from a client) should be treated as non-compliant.

Copy link
Contributor

Choose a reason for hiding this comment

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

(or put another way: Complement should not be afraid to test 'good practices' that go a little bit above and beyond the bare minimum in the spec, as long as there's no good reason why a homeserver implementer would do the opposite. In this case, I can't think of any valid reason why a homeserver should produce string power levels on its own.)

Copy link
Contributor Author

@ShadowJonathan ShadowJonathan Nov 8, 2022

Choose a reason for hiding this comment

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

Technically a server would not be in the wrong to create non-integer power levels, buuuut... I agree, I think it'd brush up against the edge of reasonable behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering there'd be no reason for it to do so and it's only 'allowed' for compatibility, I really can't see any way to defend allowing a server doing this by default in a clean test environment such as Complement.

tests/csapi/power_levels_test.go Outdated Show resolved Hide resolved
@reivilibre reivilibre merged commit 397f96f into matrix-org:main Nov 14, 2022
@ShadowJonathan ShadowJonathan deleted the 10apidoc/36room-levels branch November 14, 2022 17:59
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.

2 participants