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

footlinks: Add threshold configuration for footlinks. #841

Closed
wants to merge 1 commit into from

Conversation

Abhirup-99
Copy link
Contributor

This enables user to configure footlinks threshold settings
using footlinks_threshold in zuliprc, retiring the previous
footlinks. Tests have been updated to reflect the change.
Fixes #773.

@Abhirup-99
Copy link
Contributor Author

@neiljp pr is updated, please take a look now.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@Abhirup-99 This seems to work well - and I'd forgotten how many places we use footlinks now!

Other than the inline comments, some other general thoughts:

  • You have updated tests, but it would be great to see one for the new behavior, unless I've missed this being covered - preferably at least testing how the controller parameter affects the number of shown footlinks, and potentially that the new value gets passed in from the config file?
  • You've removed the functionality we previously had for that config option, which we have in 0.5.2; it'd be useful to allow the old option to be used, perhaps only as an alternative, but without allowing both in the file at the same time.
  • The README doesn't document the new/alternative option
  • We could add a FAQ entry about enabling/disabling/maximum footlinks, particularly in terms of how the old/new option interacts?

tests/cli/test_run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
tests/core/test_core.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Jan 12, 2021
@Abhirup-99 Abhirup-99 force-pushed the add_footlink_threshold branch 7 times, most recently from 9281799 to 77841d6 Compare January 14, 2021 16:50
@Abhirup-99
Copy link
Contributor Author

@zulipbot add "PR needs review".

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Jan 15, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@Abhirup-99 This has become quite complex for a 'good first issue', so thanks for sticking with it!
(most notably to handle the overlapping old and new config options, as well as the tests with configs)

The parameterized_zuliprc looks to be really useful for adding other tests for our config handling later 👍

We should be able to simplify the tests later if we refactor main, which you might have mentioned in the stream?

tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
"notify": "enabled",
"color-depth": "256"
}])
def test_successful_main_function_with_config(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test is with a config file but specifying the default values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, just a default value check, we can remove it though. Was writing a bunch of tests, so thought one which checks the default flow would also be useful.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think having the set of defaults passing would be a good test case, but we could integrate it with the similar pre-existing one, perhaps? I'd have to take another look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sure, but I have updated it to make it more of a successful main completion with various variations of maximum-footlinks and footlinks values.

):
modified_zuliprc = parameterized_zuliprc(minimal_zuliprc, zulip_config)
mocker.patch('zulipterminal.core.Controller.__init__',
side_effect=SystemExit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it matter that this has a side effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, without the side effect, the functions would never terminate, as it would go one with Controller initialization.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we have a number of tests which might not terminate on failing; I'd like to resolve that, but doesn't the validation failure happen before the Controller init?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The control would finish in each case whether it goes to completion with the SystemExit in Controller init or it throws errors and stops, or it stops with SystemExit in Controller init and the test fails due to the assert statements after the completion. The SystemExit are the safety nets that would ensure that in any of the above cases the control finishes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the logic to mock the calls now, rather than using SystemExit.

tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/ui/test_ui_tools.py Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Jan 16, 2021
@zulipbot zulipbot added the size: XL [Automatic label added by zulipbot] label Jan 17, 2021
@Abhirup-99
Copy link
Contributor Author

@zulipbot add "PR needs review".

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Jan 17, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@Abhirup-99 The parametrized_zuliprc is great 👍

To clarify what I said before, we want disabled=0 and enabled=3 for the new maximum levels (not 1000). If the user wants other values then they can use maximum-footlinks=[integer>=0]. Perhaps the maximum=3 was confused with enabled=3 in the previous version?

Regarding the refactor commit, I was referring to extracting something like exit_with_error("some text"). This would simplify the code slightly (include some red color, exit appropriately), but also ease testing as you can

  • mock it
  • assert on the text passed in
  • check it raises

For ensuring the Controller __init__ doesn't happen, if we mock it without a side-effect then it does nothing? We can assert that it does or doesn't get called, too, if we're supposed to exit before that point.

tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
@@ -285,6 +286,19 @@ def main(options: Optional[List[str]]=None) -> None:
else:
theme_to_use = zterm['theme']

ZULIPRC_CONFIG = 'in zuliprc file'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer we didn't rely on testing against this - this is intended for output purposes.

Perhaps we can move the validation into parse_zuliprc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But parse_zuliprc is specifically for parsing the zuliprc file, rather than validation. All other validations take place in the main function.

Comment on lines 378 to 380
# Random Large Figure which practically
# wouldn't be there in the messages
maximum_footlinks = 1000
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be 3; see my general feedback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahem. After running with the non-PR dev version quite a bit, I see lots of footlinks in some cases, so 1000 seems like a reasonable limit after all. Ideally we wouldn't use a fixed high number but something more programmatic, eg rather than comparing x to 1000 in a conditional we could wrap it and have a bool be True or False in this case, and dependent on the number otherwise.

Comment on lines 338 to 343
if zterm['footlinks'][1] == ZULIPRC_CONFIG:
print(" footlinks setting '{}' specified {}."
.format(*zterm['footlinks']))
else:
print(" maximum footlinks setting '{}' specified {}."
.format(*zterm['maximum-footlinks']))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We output this as just a maximum value in the about popup; we should make them consistent.

We could output the maximum and append an element to the last part of the zterm tuple to indicate it came from the footlinks option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That could be done, but then it would force another if clause during the traversing of zterm, and again another to check the length of the tuple during printing. Wouldn't a bit of hard-coded values and an if-else during printing be better than that approach?

@Abhirup-99 Abhirup-99 force-pushed the add_footlink_threshold branch 3 times, most recently from 495f20c to e16e1f1 Compare January 20, 2021 18:21
@Abhirup-99
Copy link
Contributor Author

@zulipbot add "PR needs review".

@Abhirup-99
Copy link
Contributor Author

@zulipbot remove "PR needs update"

@zulipbot zulipbot removed the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Jan 20, 2021
@Abhirup-99 Abhirup-99 force-pushed the add_footlink_threshold branch 2 times, most recently from b7cd789 to 9e8e23a Compare January 28, 2021 06:26
@neiljp neiljp added this to the Release after next milestone Jan 28, 2021
Base automatically changed from master to main January 30, 2021 20:31
@Abhirup-99 Abhirup-99 force-pushed the add_footlink_threshold branch 2 times, most recently from 9e3fcea to 94b57ec Compare January 31, 2021 13:12
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@Abhirup-99 This is looking really ready :)

These should all be fairly straightforward changes, but let me know if not 👍

zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
zulipterminal/cli/run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
tests/cli/test_run.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Feb 1, 2021
@Abhirup-99 Abhirup-99 force-pushed the add_footlink_threshold branch 2 times, most recently from 6e8f299 to 50c9e8e Compare February 1, 2021 17:13
@Abhirup-99
Copy link
Contributor Author

@zulipbot add "PR needs review".

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Feb 1, 2021
@Abhirup-99
Copy link
Contributor Author

@zulipbot remove "PR needs update"

@zulipbot zulipbot removed the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Feb 1, 2021
This enables the user to configure the maximum footlinks
in zuliprc. The change is backward compatible with
footlinks introduced in 0.5.2.README updated.
Fixes zulip#773.
@neiljp
Copy link
Collaborator

neiljp commented Feb 2, 2021

@Abhirup-99 Thanks for your extended work on this - I've just merged this manually as 0eeb6ea 🎉

As we discussed this does slightly change the previous meaning/behavior, which will need addressing in the release notes, or we could adjust later to be more backwards compatible.

I adjusted the general layout in various places including in the tests and made a small simplification, removed some apparent holdover code from the previous commit we already merged and clarified the commit text. I'd suggest looking into git range-diff if you haven't already for seeing what's different, though this is simple enough for a git diff between branches to see what I tweaked.

@neiljp neiljp closed this Feb 2, 2021
@Abhirup-99 Abhirup-99 deleted the add_footlink_threshold branch February 2, 2021 07:47
@Abhirup-99 Abhirup-99 restored the add_footlink_threshold branch February 2, 2021 09:36
@Abhirup-99 Abhirup-99 deleted the add_footlink_threshold branch February 2, 2021 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config PR needs review PR requires feedback to proceed size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow a threshold configuration for footlinks
3 participants