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

Adds custom user agent for requests #196

Closed
wants to merge 2 commits into from

Conversation

vkWeb
Copy link
Member

@vkWeb vkWeb commented Aug 30, 2023

Summary

This PR adds a custom user agent that adds information about morango and the product it is integrated with.

For example, with Kolibri 0.16.0, user agent should be:
User-Agent: morango/0.6.17 kolibri/0.16.0 python-requests/2.28.2
as stated on issue #191.

TODO

  • Have tests been written for the new code?
  • Has documentation been written/updated?
  • New dependencies (if any) added to requirements file

Reviewer guidance

The unit test should be sufficient I feel.

Issues addressed

Closes #191.

@vkWeb vkWeb marked this pull request as draft August 30, 2023 13:25
@vkWeb
Copy link
Member Author

vkWeb commented Sep 1, 2023

@bjester sir this PR is in draft because of two reasons:-

  • this PR was branched-off from master and its targetting release 0.7, is it correct? as I am not sure why I'm seeing Jamie sir's commit here. Though, all the code changes are mine only.

  • and sir running unit tests locally is throwing me the below error. I've installed test dependencies and did pip install -e . before running the test.

(morango-py-3.11-venv) vk@vk-sys:~/vk-workplace/morango$ pytest tests/testapp/tests/sync/test_session.py 
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 939, in _find_spec
AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/bin/pytest", line 8, in <module>
    sys.exit(main())
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 55, in main
    config = _prepareconfig(args, plugins)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 179, in _prepareconfig
    return pluginmanager.hook.pytest_cmdline_parse(
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_hooks.py", line 493, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_manager.py", line 115, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_callers.py", line 130, in _multicall
    teardown[0].send(outcome)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_result.py", line 114, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_callers.py", line 77, in _multicall
    res = hook_impl.function(*args)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 612, in pytest_cmdline_parse
    self.parse(args)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 777, in parse
    self._preparse(args, addopts=addopts)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/config/__init__.py", line 729, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/pluggy/_manager.py", line 398, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 941, in _find_spec
  File "<frozen importlib._bootstrap>", line 915, in _find_spec_legacy
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 149, in find_module
    source_stat, co = _rewrite_test(self.config, fn_pypath)
  File "/home/vk/vk-workplace/morango/morango-py-3.11-venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 344, in _rewrite_test
    co = compile(tree, fn.strpath, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias

@bjester
Copy link
Member

bjester commented Sep 1, 2023

Ah sorry @vkWeb, master is out of date. We're having issues integrating 0.7.x into Kolibri, and may jump to 0.8.x after we deprecate python2.7 in Kolibri. So all that said, the best branch to base off would be release-v0.6.x.

Furthermore, I updated/fixed the GH actions in the release-v0.7.x branch, but not in release-v0.6.x so there will be GH action failures there. I want to resolve that but for a workaround in the time being, you could open a full PR to release-v0.6.x for merging, and a second draft to release-v0.7.x just so that we can verify the tests. But overall, I think your changes are fairly safe.

Perhaps the above will resolve some that strange issue you shared

@vkWeb vkWeb mentioned this pull request Sep 11, 2023
3 tasks
@vkWeb vkWeb closed this Sep 11, 2023
@vkWeb vkWeb deleted the user-agent branch September 11, 2023 09:28
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.

Add custom user-agent to requests
3 participants