diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a1a70b05f..bb53cd07c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -22,7 +22,7 @@ participating in this project you agree to abide by its terms. ## Responding to Issues -One of the simplest ways to help with PRAW is by answering others' +One of the simplest ways to help with Async PRAW is by answering others' questions. When responding, always be positive. While something may be obvious to you, it likely is not to the person asking the question. @@ -32,24 +32,24 @@ to you, it likely is not to the person asking the question. commenting on the issue. This act will hopefully minimize any duplicate work. -0. Prior to creating a pull request run the `pre_push.py` script. This script - depends on the tools `black` `flake8`, `pylint`, `pydocstyle`, `sphinx` and `sphinx_rtd_theme`. They can - be installed via `pip install black flake8 pydocstyle pylint sphinx sphinx_rtd_theme` or via +1. Prior to creating a pull request run the `pre_push.py` script. This script + depends on the tools `black` `flake8`, `pylint`, `pydocstyle`, `sphinx`, `sphinx_rtd_theme`, and `sphinxcontrib-trio`. They can + be installed via `pip install black flake8 pydocstyle pylint sphinx sphinx_rtd_theme sphinxcontrib-trio` or via `pip install asyncpraw[lint]`. -0. Add yourself as a contributor to the ``AUTHORS.rst``. +2. Add yourself as a contributor to the ``AUTHORS.rst``. -0. Once pushed, ensure that your Github Actions build succeeds. Actions will error +3. Once pushed, ensure that your Github Actions build succeeds. Actions will error before running any tests if there are _any_ `flake8` or `pydocstyle` issues. Resolve any issues by updating your pull request. -0. Ensure that your change has complete test coverage. Tests on methods that do +4. Ensure that your change has complete test coverage. Tests on methods that do not require fetching data from Reddit, e.g., method argument validation, should be saved as a unit test. Tests that hit Reddit's servers should be an - integration test and all network activity should be recorded via Betamax. + integration test and all network activity should be recorded via vcrpy. The required packages can be installed with `pip install asyncpraw[test]`. -0. Feel free to check on the status of your pull request periodically by adding +5. Feel free to check on the status of your pull request periodically by adding a comment. ## Becoming a Team Member @@ -61,7 +61,7 @@ we would like to see you push a number of contributions before we add you on. ## Style Recommendations -To keep PRAW's source consistent, all contribution code must pass the +To keep Async PRAW's source consistent, all contribution code must pass the `pre_push.py` script. Github Actions will enforce the passing of the automated tests, as well as style checking done via the `pre_push.py` script. While this script helps ensure consistency with much of PEP8 and PEP257 there are a few @@ -90,8 +90,7 @@ from os.path import abspath, join import sys import traceback -from prawcore import NotFound -import requests +from asyncprawcore import NotFound from ...const import API_PATH from ..listing.mixins import SubmissionListingMixin diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 11f160159..720163c40 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,6 +24,6 @@ Steps to reproduce the behavior: **System Info** - - OS: - - Python: - - PRAW Version: + - OS: + - Python: + - Async PRAW Version: diff --git a/CHANGES.rst b/CHANGES.rst index 759428965..becdbe4ea 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Change Log ========== +7.1.0 (2020/07/15) +------------------ + +* Initial Async PRAW Release. + For changes in PRAW please see: `PRAW Changelog `_ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f797503f4..6d7a62cc1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at bbzbryce@gmail.com. All complaints will be reviewed and investigated promptly and fairly. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lilspazjoekp@gmail.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. @@ -82,4 +82,3 @@ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcem For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. - diff --git a/asyncpraw/config.py b/asyncpraw/config.py index 4430118b3..cd6c801bf 100644 --- a/asyncpraw/config.py +++ b/asyncpraw/config.py @@ -29,12 +29,6 @@ class Config: "extended": configparser.ExtendedInterpolation, } - @staticmethod - def _config_boolean(item): - if isinstance(item, bool): - return item - return item.lower() in {"1", "yes", "true", "on"} - @classmethod def _load_config(cls, config_interpolation: Optional[str] = None): """Attempt to load settings from various praw.ini files.""" @@ -107,9 +101,6 @@ def _fetch_or_not_set(self, key): def _initialize_attributes(self): self._short_url = self._fetch_default("short_url") or self.CONFIG_NOT_SET - self.check_for_updates = self._config_boolean( - self._fetch_or_not_set("check_for_updates") - ) self.kinds = { x: self._fetch("{}_kind".format(x)) for x in [ diff --git a/asyncpraw/models/reddit/live.py b/asyncpraw/models/reddit/live.py index cec58d55f..7d9b4db12 100644 --- a/asyncpraw/models/reddit/live.py +++ b/asyncpraw/models/reddit/live.py @@ -604,7 +604,6 @@ async def update( } url = API_PATH["live_update_thread"].format(id=self.thread.id) - # prawcore (0.7.0) Session.request() modifies `data` kwarg await self.thread._reddit.post(url, data=data.copy()) self.thread._reset_attributes(*data.keys()) diff --git a/asyncpraw/models/reddit/submission.py b/asyncpraw/models/reddit/submission.py index 01b5f7d91..51327dea7 100644 --- a/asyncpraw/models/reddit/submission.py +++ b/asyncpraw/models/reddit/submission.py @@ -269,7 +269,7 @@ async def sticky(self, state: bool = True, bottom: bool = True): .. note:: When a submission is stickied two or more times, the Reddit API responds with a 409 error that is raises as a ``Conflict`` by - PRAWCore. The method suppresses these ``Conflict`` errors. + asyncprawcore. The method suppresses these ``Conflict`` errors. This submission will replace the second stickied submission if one exists. diff --git a/asyncpraw/models/reddit/subreddit.py b/asyncpraw/models/reddit/subreddit.py index 416767094..3dd9e2b27 100644 --- a/asyncpraw/models/reddit/subreddit.py +++ b/asyncpraw/models/reddit/subreddit.py @@ -3416,7 +3416,7 @@ async def upload_banner(self, image_path): :param image_path: A path to a jpeg or png image. - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very @@ -3442,7 +3442,7 @@ async def upload_banner_additional_image(self, image_path, align=None): :param align: Either ``left``, ``centered``, or ``right``. (default: ``left``). - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very @@ -3479,7 +3479,7 @@ async def upload_banner_hover_image(self, image_path): Fails if the Subreddit does not have an additional image defined - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very @@ -3505,7 +3505,7 @@ async def upload_header(self, image_path): :returns: A dictionary containing a link to the uploaded image under the key ``img_src``. - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very @@ -3529,7 +3529,7 @@ async def upload_mobile_header(self, image_path): :returns: A dictionary containing a link to the uploaded image under the key ``img_src``. - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very @@ -3553,7 +3553,7 @@ async def upload_mobile_icon(self, image_path): :returns: A dictionary containing a link to the uploaded image under the key ``img_src``. - Raises ``prawcore.TooLarge`` if the overall request body is too large. + Raises ``asyncprawcore.TooLarge`` if the overall request body is too large. Raises :class:`.RedditAPIException` if there are other issues with the uploaded image. Unfortunately the exception info might not be very diff --git a/asyncpraw/praw.ini b/asyncpraw/praw.ini index fe29a1ba0..59c5855a8 100644 --- a/asyncpraw/praw.ini +++ b/asyncpraw/praw.ini @@ -1,6 +1,4 @@ [DEFAULT] -# A boolean to indicate whether or not to check for package updates. -check_for_updates=True # Object to kind mappings comment_kind=t1 diff --git a/asyncpraw/reddit.py b/asyncpraw/reddit.py index 236df6806..3368a70af 100644 --- a/asyncpraw/reddit.py +++ b/asyncpraw/reddit.py @@ -23,7 +23,7 @@ from . import models from .config import Config -from .const import API_PATH, USER_AGENT_FORMAT, __version__ +from .const import API_PATH, USER_AGENT_FORMAT from .exceptions import ( ClientException, MissingRequiredAttributeException, @@ -31,13 +31,6 @@ ) from .objector import Objector -try: - from update_checker import update_check - - UPDATE_CHECKER_MISSING = False -except ImportError: # pragma: no cover - UPDATE_CHECKER_MISSING = True - Comment = models.Comment Redditor = models.Redditor @@ -63,7 +56,6 @@ class Reddit: """ - update_checked = False _ratelimit_regex = re.compile(r"([0-9]{1,2}) (seconds?|minutes?)") @property @@ -146,7 +138,7 @@ def __init__( variable praw_site. If it is not found there, the DEFAULT site will be used. :param requestor_class: A class that will be used to create a - requestor. If not set, use ``prawcore.Requestor`` (default: None). + requestor. If not set, use ``asyncprawcore.Requestor`` (default: None). :param requestor_kwargs: Dictionary with additional keyword arguments used to initialize the requestor (default: None). @@ -228,9 +220,8 @@ async def request(self, *args, **kwargs): "to the `Reddit` class constructor." ) - self._check_for_update() self._prepare_objector() - self._prepare_prawcore(requestor_class, requestor_kwargs) + self._prepare_asyncprawcore(requestor_class, requestor_kwargs) self.auth = models.Auth(self, None) """An instance of :class:`.Auth`. @@ -370,13 +361,6 @@ async def request(self, *args, **kwargs): """ - def _check_for_update(self): - if UPDATE_CHECKER_MISSING: - return - if not Reddit.update_checked and self.config.check_for_updates: - update_check(__package__, __version__) - Reddit.update_checked = True - def _prepare_objector(self): mappings = { self.config.kinds["comment"]: models.Comment, @@ -418,7 +402,7 @@ def _prepare_objector(self): } self._objector = Objector(self, mappings) - def _prepare_prawcore(self, requestor_class=None, requestor_kwargs=None): + def _prepare_asyncprawcore(self, requestor_class=None, requestor_kwargs=None): requestor_class = requestor_class or Requestor requestor_kwargs = requestor_kwargs or {} @@ -430,11 +414,11 @@ def _prepare_prawcore(self, requestor_class=None, requestor_kwargs=None): ) if self.config.client_secret: - self._prepare_trusted_prawcore(requestor) + self._prepare_trusted_asyncprawcore(requestor) else: - self._prepare_untrusted_prawcore(requestor) + self._prepare_untrusted_asyncprawcore(requestor) - def _prepare_trusted_prawcore(self, requestor): + def _prepare_trusted_asyncprawcore(self, requestor): authenticator = TrustedAuthenticator( requestor, self.config.client_id, @@ -455,7 +439,7 @@ def _prepare_trusted_prawcore(self, requestor): else: self._core = self._read_only_core - def _prepare_untrusted_prawcore(self, requestor): + def _prepare_untrusted_asyncprawcore(self, requestor): authenticator = UntrustedAuthenticator( requestor, self.config.client_id, self.config.redirect_uri ) diff --git a/docs/conf.py b/docs/conf.py index fe8272c3d..ed8e1a6d0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,17 +8,17 @@ from asyncpraw import __version__ -copyright = "2020, Bryce Boe" +copyright = "2020, Joel Payne" exclude_patterns = ["_build"] extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinxcontrib_trio"] html_static_path = ["_static"] html_theme = "sphinx_rtd_theme" html_theme_options = {"collapse_navigation": True} -htmlhelp_basename = "PRAW" +htmlhelp_basename = "Async PRAW" intersphinx_mapping = {"python": ("https://docs.python.org/3.8", None)} master_doc = "index" nitpicky = True -project = "PRAW" +project = "Async PRAW" pygments_style = "sphinx" release = __version__ source_suffix = ".rst" diff --git a/docs/getting_started/configuration.rst b/docs/getting_started/configuration.rst index a5007c5f3..5dad7e162 100644 --- a/docs/getting_started/configuration.rst +++ b/docs/getting_started/configuration.rst @@ -3,6 +3,10 @@ Configuring Async PRAW ====================== +.. note:: + + Async PRAW is fully compatible with the configuration system that PRAW uses. + .. toctree:: :maxdepth: 2 diff --git a/docs/getting_started/configuration/environment_variables.rst b/docs/getting_started/configuration/environment_variables.rst index 08c50002b..c59a5f7b5 100644 --- a/docs/getting_started/configuration/environment_variables.rst +++ b/docs/getting_started/configuration/environment_variables.rst @@ -3,7 +3,6 @@ Async PRAW Environment Variables ================================ -Async PRAW uses the same environment variables as PRAW. The second-highest priority configuration options can be passed to a program via environment variables prefixed with ``praw_``. diff --git a/docs/getting_started/configuration/reddit_initialization.rst b/docs/getting_started/configuration/reddit_initialization.rst index 4b21ffca4..2d302f0f8 100644 --- a/docs/getting_started/configuration/reddit_initialization.rst +++ b/docs/getting_started/configuration/reddit_initialization.rst @@ -3,10 +3,10 @@ Keyword Arguments to :class:`.Reddit` ===================================== -Most of Async PRAW's documentation will demonstrate configuring Async PRAW through the use -of keyword arguments when initializing instances of :class:`.Reddit`. All of -the :ref:`configuration_options` can be specified using a keyword argument of -the same name. +Most of Async PRAW's documentation will demonstrate configuring Async PRAW +through the use of keyword arguments when initializing instances of +:class:`.Reddit`. All of the :ref:`configuration_options` can be specified +using a keyword argument of the same name. For example, if we wanted to explicitly pass the information for ``bot3`` defined in :ref:`the praw.ini custom site example ` diff --git a/docs/getting_started/faq.rst b/docs/getting_started/faq.rst index 5c1315114..a5fc8ce2c 100644 --- a/docs/getting_started/faq.rst +++ b/docs/getting_started/faq.rst @@ -5,13 +5,23 @@ Frequently Asked Questions Q: How can I refresh a comment/subreddit/submission? -A: Directly calling the constructors will refresh the value: +A: There is two ways to do this: -.. code-block:: python + * Directly calling the constructors will refresh the value: + + .. code-block:: python + + await reddit.comment(id=comment.id) + await reddit.subreddit(display_name=subreddit.display_name) + await reddit.submission(id=submission.id) + + * Calling :meth:`~.RedditBase.load`: + + .. code-block:: python - await reddit.comment(id=comment.id) - await reddit.subreddit(display_name=subreddit.display_name) - await reddit.submission(id=submission.id) + await comment.load() + await subreddit.load() + await submission.load() .. _faq2: diff --git a/docs/getting_started/installation.rst b/docs/getting_started/installation.rst index 3c1c8335e..9de8d8eb1 100644 --- a/docs/getting_started/installation.rst +++ b/docs/getting_started/installation.rst @@ -34,7 +34,7 @@ part of the installation command: .. code-block:: bash - pip install asyncpraw==7.0.0 + pip install asyncpraw==7.1.0 Installing the Latest Development Version ----------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index 4e998e3f8..4a5bb04eb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -55,6 +55,7 @@ applications and **web** applications. package_info/change_log package_info/contributing package_info/glossary + package_info/asyncpraw_migration package_info/praw7_migration package_info/references diff --git a/docs/package_info/asyncpraw_migration.rst b/docs/package_info/asyncpraw_migration.rst new file mode 100644 index 000000000..aa60909ef --- /dev/null +++ b/docs/package_info/asyncpraw_migration.rst @@ -0,0 +1,100 @@ +Migrating to Async PRAW +======================= + +With the conversion to async, there are few critical changes that had to be made. +This page outlines a few those changes. + +Network Requests +---------------- + +.. _network_requests: + +Since Async PRAW will be operating in an asynchronous environment using +`aiohttp `_ and thus anytime it could make a network request +it needs to be awaited. The majority of all methods need to be awaited. + + +Lazy Loading +------------ + +.. _lazy_loading: + +In PRAW, the majority of objects are lazily loaded and are not fetched until an +attribute is accessed. With Async PRAW, objects can be fetched on initialization and +some now do this by default. For example: + +* PRAW: + + .. code-block:: python + + submission = reddit.submission('id') # network request is not made and object is lazily loaded + print(submission.score) # network request is made and object is fully fetched + +* Async PRAW: + + .. code-block:: python + + submission = await reddit.submission('id') # network request made and object is fully loaded + print(submission.score) # network request is not made as object is already fully fetched + +Now, lazy loading is not gone completely and can still be done. For example, if you +only wanted to remove a post, you don't need the object fully fetched to do that. + +* PRAW + + .. code-block:: python + + reddit.submission('id').mod.remove() # object is not fetched and is only removed + +* Async PRAW: + + .. code-block:: python + + submission = await reddit.submission('id', lazy=True) # network request is not made and object is lazily loaded + await submission.mod.remove() # object is not fetched and is only removed + +By default, only :class:`.Subreddit`, :class:`.Redditor`, :class:`.LiveThread`, +and :class:`.Multireddit` objects are still lazily loaded. You can pass ``fetch=True`` +in the initialization of the object to fully load it. Inversely, the following objects +are now fully fetched when initialized: :class:`.Submission`, :class:`.Comment`, +:class:`.WikiPage`, :class:`.RemovalReason`, :class:`.Collection`, :class:`.Emoji`, +:class:`.LiveUpdate`, :class:`.Rule`, and :class:`.Preferences`. You can pass +``lazy=True`` if you want to lazily loaded it. + +In addition, there will be a ``load()`` method provided for manually fetching/refreshing +objects that subclass :class:`.RedditBase`. If you need to later on access an attribute +you need to call the ``.load()`` method first: + + .. code-block:: python + + submission = await reddit.submission('id', lazy=True) # object is lazily loaded and no requests are made + ... + await submission.load() + print(submission.score) # network request is not made as object is already fully fetched + +Getting items by Indices +------------------------ + +.. _objects_by_indices: + +In PRAW you could get specific :class:`.WikiPage`, :class:`.RemovalReason`, :class:`.Emoji`, +:class:`.LiveUpdate`, and :class:`.Rule` objects by using string indices. This will no longer +work and has been converted to a ``.get_(item)`` method. Also, they are not lazily +loaded by default anymore. + +* PRAW: + + .. code-block:: python + + page = subreddit.wiki['page'] # lazily creates a WikiPage instance + print(page.content_md) # network request is made and item is fully fetched + +* Async PRAW: + + .. code-block:: python + + page = await subreddit.wiki.get_page('page') # network request made and object is fully loaded + print(page.content_md) # network request is not made as WikiPage is already fully fetched`` + + # using slices + rule = await subreddit.mod.rules.get_rule(slice(-3,None)) # to get the last 3 rules \ No newline at end of file diff --git a/docs/package_info/contributing.rst b/docs/package_info/contributing.rst index 6ea9a12d9..bd85f14da 100644 --- a/docs/package_info/contributing.rst +++ b/docs/package_info/contributing.rst @@ -50,12 +50,20 @@ Running the Test Suite all updates to known branches and pull requests. However, it's useful to be able to run the tests locally. The simplest way is via: -.. code:: bash +.. code-block:: bash - pytest + pytest Without any configuration or modification, all the tests should pass. +.. note:: + + Async PRAW uses a fork of `vcrpy` before you can run tests locally you must install the forked version. + .. code-block:: bash + + pip install https://github.com/LilSpazJoekp/vcrpy/archive/asyncpraw.zip + + Adding and Updating Integration Tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -126,7 +134,7 @@ For feature additions, bugfixes, or code removal please add an appropriate entry to ``CHANGES.rst``. If the ``Unreleased`` section does not exist at the top of ``CHANGES.rst`` please add it. See `commit 280525c16ba28cdd69cdbb272a0e2764b1c7e6a0 -`_ +`_ for an example. See Also diff --git a/docs/package_info/references.rst b/docs/package_info/references.rst index 92e93c028..919ab47ad 100644 --- a/docs/package_info/references.rst +++ b/docs/package_info/references.rst @@ -1,7 +1,8 @@ References ========== -* `PRAW Source Code `_. +* `Async PRAW Source Code `_. +* `PRAW Source Code `_. * `Reddit Source Code `_. This repository has been archived and is no longer updated. * `Reddit API Wiki Page `_. diff --git a/pyproject.toml b/pyproject.toml index 9541b418b..ad717f0f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] -exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|env\.nosync|_build|buck-out|build|dist)/' +exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist)/' line-length = 88 diff --git a/setup.py b/setup.py index 57795484f..5268a7929 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ "reddit's API." ), extras_require=extras, - install_requires=["asyncprawcore >=1.0.1, <2.0", "update_checker >=0.17"], + install_requires=["asyncprawcore >=1.0.1, <2.0"], keywords="reddit api wrapper async asynchronous praw", license="Simplified BSD License", long_description=README, diff --git a/tests/conftest.py b/tests/conftest.py index 239e952cd..48e44cb45 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -49,9 +49,6 @@ def filter_access_token(response): return response -os.environ["praw_check_for_updates"] = "False" - - placeholders = { x: env_default(x) for x in ( diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 6be74092d..18f8cab4b 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -41,11 +41,6 @@ def _assert_config_read(environment, mock_config): else: os.environ[env_name] = prev_environment[env_name] - def test_check_for_updates__false(self): - for value in [False, "False", "other"]: - config = Config("DEFAULT", check_for_updates=value) - assert config.check_for_updates is False - def test_custom__extra_values_set(self): config = Config("DEFAULT", user1="foo", user2="bar") assert config.custom == {"user1": "foo", "user2": "bar"} @@ -54,11 +49,6 @@ def test_custom__no_extra_values_set(self): config = Config("DEFAULT") assert config.custom == {} - def test_check_for_updates__true(self): - for value in [True, "1", "true", "YES", "on"]: - config = Config("DEFAULT", check_for_updates=value) - assert config.check_for_updates is True - @mock.patch("configparser.ConfigParser") def test_load_ini_from_appdata(self, mock_config): self._assert_config_read("APPDATA", mock_config) diff --git a/tests/unit/test_reddit.py b/tests/unit/test_reddit.py index 5ca0e2fb5..7d7da8ee5 100644 --- a/tests/unit/test_reddit.py +++ b/tests/unit/test_reddit.py @@ -7,7 +7,7 @@ from asyncprawcore import Requestor from asyncprawcore.exceptions import BadRequest -from asyncpraw import Reddit, __version__ +from asyncpraw import Reddit from asyncpraw.config import Config from asyncpraw.exceptions import ClientException, RedditAPIException from asyncpraw.models import Comment @@ -20,28 +20,12 @@ class TestReddit(UnitTest): x: "dummy" for x in ["client_id", "client_secret", "user_agent"] } - @mock.patch("asyncpraw.reddit.update_check", create=True) - @mock.patch("asyncpraw.reddit.UPDATE_CHECKER_MISSING", False) - @mock.patch("asyncpraw.reddit.Reddit.update_checked", False) - def test_check_for_updates(self, mock_update_check): - Reddit(check_for_updates="1", **self.REQUIRED_DUMMY_SETTINGS) - assert Reddit.update_checked - mock_update_check.assert_called_with("asyncpraw", __version__) - - @mock.patch("asyncpraw.reddit.update_check", create=True) - @mock.patch("asyncpraw.reddit.UPDATE_CHECKER_MISSING", True) - @mock.patch("asyncpraw.reddit.Reddit.update_checked", False) - def test_check_for_updates_update_checker_missing(self, mock_update_check): - Reddit(check_for_updates="1", **self.REQUIRED_DUMMY_SETTINGS) - assert not Reddit.update_checked - assert not mock_update_check.called - def test_comment(self): assert Comment(self.reddit, id="cklfmye").id == "cklfmye" def test_context_manager(self): with Reddit(**self.REQUIRED_DUMMY_SETTINGS) as reddit: - assert not reddit.config.check_for_updates + assert not reddit._validate_on_submit def test_info__invalid_param(self): with pytest.raises(TypeError) as excinfo: