summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_torrent.py
Commit message (Collapse)AuthorAge
* Automatically refresh and expire the torrent status cache.Chase Sterling2022-02-15
| | | | | | | | | | Stop at ratio was not working when no clients were connected, because it was using a cached version of the torrent status, and never calling for a refresh. When a client connected, it called for the refresh and started working properly. Closes: https://dev.deluge-torrent.org/ticket/3497 Closes: https://github.com/deluge-torrent/deluge/pull/369
* [Core] Stopped using libtorrent deprecated functionsDjLegolas2022-02-13
| | | | | | | | | | | | | | | | | As part of the process of adding support to LT 2.0, we should stop using all deprecated function, as some (if not all) were removed. For this process, we should use the LT 1.2 upgrade (guide)[1]. The change includes: * stop using file entries directly * start using the torrent handle's set/unset flags * stop using url key in add_torrent_params (for magnet) * stop accessing resume_data from save_resume_data_alert * stop using deprecated session status keys in UI [1] https://libtorrent.org/upgrade_to_1.2-ref.html Closes: https://dev.deluge-torrent.org/ticket/3499 Closes: https://github.com/deluge-torrent/deluge/pull/342
* [Tests] Make file priority test more consistent.Chase Sterling2022-02-12
| | | | | | | | | | | Our file priority test was using time.sleep to wait until libtorrent had processed the command. This was sometimes not long enough and the test would fail. On libtorrent 2.0.3+ there is an alert when the process has finished, switch to waiting for that in this test to make the test more consistent. On older libtorrent, make the delay a bit longer, to try to make the test more consistent there as well. Closes: https://github.com/deluge-torrent/deluge/pull/373
* [Tests] Transition tests to pure pytestChase Sterling2022-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert all the twisted.trial tests to pytest_twisted. Also move off of unittest.TestCase as well. Seems there were several tests which weren't actually testing what they should, and also some code that wasn't doing what the broken test said it should. Goals: Remove twisted.trial tests Move to pytest fixtures, rather than many classess and subclasses with setup and teardown functions Move away from self.assertX to assert style tests FIx broken tests Going forward I think these should be the goals when adding/modifying tests: * Don't use BaseTest or set_up tear_down methods any more. Fixtures should be used either in the test module/class, or make/improve the ones available in conftest.py * For sure don't use unittest or twisted.trial, they mess up the pytest stuff. * Prefer pytest_twisted.ensureDeferred with an async function over inlineCallbacks. - I think the async function syntax is nicer, and it helps catch silly mistakes, e.g. await None is invalid, but yield None isn't, so if some function returns an unexpected thing we try to await on, it will be caught earlier. (I struggled debugging a test for quite a while, then caught it immediately when switching to the new syntax) - Once the maybe_coroutine PR goes in, using the async syntax can also improve tracebacks when debugging tests. Things that should probably be cleaned up going forward: * Remove BaseTestCase * Remove the subclasses like DaemonBase in favor of new fixtures. * I think there are some other utility subclasses that could be removed too * Perhaps use parameterization in the ui_entry tests, rather that the weird combination of subclasses and the set_var fixture I mixed in. * Convert some of the callback stuff to pytest_twisted.ensureDeferred tests, just for nicer readability Details relating to pytest fixtures conftest.py in root dir: * https://github.com/pytest-dev/pytest/issues/5822#issuecomment-697331920 * https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files Closes: https://github.com/deluge-torrent/deluge/pull/354
* [Tests] Enable more tests that now work on WindowsChase Sterling2022-01-26
|
* Upgrade codebase with pyupgrade (>=py3.6)DjLegolas2021-12-29
| | | | | | | | Added pyupgrade utility with manual stage to pre-commit and run on all files. Ref: https://github.com/asottile/pyupgrade Closes: deluge-torrent/deluge#326
* Remove all Python 2 supportdeluge-2.1.0.dev0DjLegolas2021-12-28
| | | | | | | | | * Removed all __future__ imports from code * Removed all six dependencies * Removed all future_builtins imports * Removed all Python 2 related code Closes: deluge-torrent/deluge#325
* [Tests] Fix skipping torrent test for libtorrent >= 1.2Calum Lind2021-08-01
| | | | Test is still failing with libtorrent 2 so also skip.
* [Tests] Fix incorrent twisted defer importCalum Lind2021-07-31
| | | | | With the release Twisted 21.7.0 there was an import error running the tests due to defer incorrectly imported via twisted.internet.tasks module.
* [CI/CD] Add github actions to replace TravisCalum Lind2021-07-25
| | | | | | | | | | | | | | | | Due to new limitations for open-source projects on Travis we are switching to GitHub actions. * Notes about system site-packages We had many problems with accessing system python packages on Travis for libtorrent and GTK and the problems are harder on Github since there is no more access. For now copying the python libtorrent binary into the deluge source is the workaround. There is a pip package that could be used in future. Fixed failing tests with libtorrent 1.2 which required a non-zero length file in torrent and workarounds for async alert delay.
* [#3348] Fix TypeError adding peers to torrentsCalum Lind2020-04-25
| | | | | | | | | | | Python3 has stricter type checking and passing a port as string results in libtorrent raising a TypeError. Fixed by casting port to int, along with refactoring to ensure ipv6 is correctly parsing and a useful error is output to user with invalid ip or port details. https://dev.deluge-torrent.org/ticket/3348
* [Travis] Add unit test for libtorrent 1.2Calum Lind2019-06-05
| | | | | | | Skip test_torrent_error_resume_original_state on libtorrent 1.2 as it is failing for an unknown reason. Refs: #3255
* [Core] Update to support libtorrent 1.2DjLegolas2019-06-05
| | | | | | | | | | Some changes between lt 1.1 and 1.2 require updates to core code. - Switch from proxy_type to proxy_type_t - Replace hardcoded flag value with add_torrent_params_flags_t since 1.2 uses different flag values. - add_torrent_params requires flags set instead of dict values. Refs: #3255
* [UI|Core] Fix problems with file prioritiesCalum Lind2018-11-05
| | | | | | | - Fixed the core not correctly settings the current file_priority settings and added a test. - Fixed the console not setting file priorities. - Change the label for not downloading of a file to 'Skip'.
* [Core] Fix potential renaming unicode folders issueCalum Lind2018-10-22
| | | | | | | | | - Found an issue while fixing `get_name` where `handle.rename_file` would raise a UnicodeDecodeError with non-ascii on Python 2. The fix is to catch this and pass unicode string to method instead. - Add a test `test_rename_unicode` to verify no errors are generated. - Updated test to use core.session instead of creating another one.
* [#3204|Core] Fix unicode get_name unicode errorCalum Lind2018-10-22
| | | | | | | | | The recent change to torrent.get_name does not handle non-ascii paths on Python 2. - Add a decode_bytes to resolve the issue. - Add tests. - Refactor to reduce nesting.
* [Lint] Use Black to auto-format codeCalum Lind2018-10-03
| | | | | | | | | | | | | | | | | The move to using auto-formatter makes it easier to read, submit and speeds up development time. https://github.com/ambv/black/ Although I would prefer 79 chars, the default line length of 88 chars used by black suffices. The flake8 line length remains at 120 chars since black does not touch comments or docstrings and this will require another round of fixes. The only black setting that is not standard is the use of double-quotes for strings so disabled any formatting of these. Note however that flake8 will still flag usage of double-quotes. I may change my mind on double vs single quotes but for now leave them. A new pyproject.toml file has been created for black configuration.
* [Py2to3] Fix opening torrent files in byte modeCalum Lind2018-09-14
|
* [Core] Fix get_eta returning float instead of intCalum Lind2018-07-16
| | | | | | | | Floor division will return a float if a float is provided so ensure int when dividing by the stop_ratio. All other status values from libtorrent are ints. Added tests.
* [Py2to3] Replace deprecated base64.(de|en)codestringCalum Lind2018-06-26
| | | | | | * In Py3 base64.encodestring is deprecated so rather than use the Py3 only encodebytes instead use b64encode. The other advantage is that with issue a consistent TypeError is raised that we can catch.
* Skip Failing Tests On WindowsUnknown2018-06-02
|
* Fix files to pass new Flake8 checkersCalum Lind2018-06-01
| | | | | | | | | | | Some new flake8 checkers were added so fix these new warnings and any issues uncovered. Use add-trailing-comma to fix missing trailing commas. It does not format it as well as I would like however it was fast to change and helps with git changes in future. Removed pylint from tox due to large number of warnings.
* [Tests] Fix 'Too many open files' by disabling LSDCalum Lind2018-05-19
| | | | | | Instances of libtorrent with Local Service Discovery enabled are leaving many sockets fd open with every test run and will fail with 'Too many files open' if ulimit is >=1024.
* [Tests] Ensure tear_down deletes rpcserver and coreCalum Lind2018-05-19
|
* Delay assert in test_torrent for TravisCalum Lind2017-12-16
|
* [#3126|Core] Restore synchonous add torrent methods for backward compatibiltyCalum Lind2017-11-18
| | | | | | | | | | | | | The synchonous add torrent method was replaced with async but this break backward compatibility with 3rd party plugins and clients. Added a new add_torrent_file_async method for adding single torrent. Torrent manager has a new add_async method and split up code to prevent duplication. Update any use of add_torrent_file to add_torrent_file_async. Future refactoring could use add_torrent_files instead.
* [#2966] [Tests] Rename deprecated method aliasesCalum Lind2017-03-19
|
* [Common] Rename decode_string to decode_bytesCalum Lind2017-02-23
| | | | | | | - Switch to using Python 3 naming convention where str now refers to unicode and bytes are encoded strings. - Cleanup docs and code - Also rename convert_to_utf8 to utf8_encode_structure to clarify functionality.
* [Tests] Markup byte strings to fix testsCalum Lind2017-02-22
|
* [Lint] Add missing copyright header to filesCalum Lind2017-02-22
|
* [Py2to3] Force unicode_literals and fix related issuesCalum Lind2017-02-22
| | | | | | | | | | | | | | | | | | * Added `from __future__ import unicode_literals` to every file so now all strings in code are forced to be unicode strings unless marked as byte string `b'str'` or encoded to byte string `'str'.encode('utf-8')`. This is a large change but we have been working towards the goal of unicode strings passed in the code so decoding external input and encoding output as byte strings (where applicable). Note that in Python 2 the `str` type still refers to byte strings. * Replaced the use of `str` for `basestring` in isinstance comparison as this was the original intention but breaks code when encoutering unicode strings. * Marked byte strings in gtkui as the conversion to utf8 is not always handled, mostly related to gobject signal names.
* [Core] Remove all lt 1.1 deprecated code referencesCalum Lind2017-01-18
|
* [Core] Refactor of priorities code and testCalum Lind2016-11-30
|
* [Lint] Convert all python double quotes to single quotesCalum Lind2016-11-03
| | | | | | | | | | | | | | | | | | * A rather disruptive change but for a few reasons such as easier to read, easier type, keep consistent and javascript code uses single quotes. * There are a few exceptions for the automated process: * Any double quotes in comments * Triple double quotes for docstrings * Strings containing single quotes are left e.g. "they're" * To deal with merge conflicts from feature branches it is best to follow these steps for each commit: * Create a patch: `git format-patch -1 <sha1>` * Edit the patch and replace double quotes with single except those in comments or strings containing an unescaped apostrophe. * Check the patch `git apply --check <patchfile>` and fix any remaining issues if it outputs an error. * Apply the patch `git am < <patchfile>`
* [Tests] Move test torrents into data subdirbendikro2016-11-01
|
* [Tests] Use common.rpath() in all testsbendikro2016-10-18
|
* [#2889] Fixes for 'Too many files open' errorCalum Lind2016-10-18
| | | | | | | | * Ensure all file descriptors are closed. Using the with statement ensures closure. * The main problem was with thousands of unclosed file desciptors from tracker_icons mkstemp. * Use a prefix 'deluge_ticon.' to identify created tracker_icon tmp files.
* [Tests] Inherit from BaseTestCase in testcasesbendikro2016-05-24
| | | | | | * Testcases in test_torrent.py and test_torrentmanager.py creates components and should therefore inherit from BaseTestCase. * Cleanup in test_json_api.py
* [Core] Implement async_add_torrent in torrentmanagerbendikro2016-04-10
|
* [GTKUI] Cleanup code duplication in TabsCalum Lind2015-12-12
|
* [Tests] Move test_torrent_error code into test_torrentCalum Lind2015-12-12
|
* [Core] Emit TorrentStateChangedEvent in update_stateCalum Lind2015-09-29
|
* Added .travis.yml (for travis-ci) and tox.ini filesbendikro2014-09-25
| | | | | | | | | | | | | | | | | | | Targets: * Runs the unit-tests for python 2.7 * Tests unit-test coverage * Try to build docs * Code style checks: * flake8 * isort Codes changes: * Fixed tests for httpdownloader (using tmp dir) * Implemented a couple of tests for Stats plugin but they fail to run on travis Issues: * Can't get py26 to work because of installing libtorrent through apt and the option system_site_packages fails for 2.6.
* Autopep8 E265Calum Lind2014-09-22
|
* Flake8 pass of entire codebaseCalum Lind2014-09-19
| | | | * Use the inline '# NOQA' to supress N802 lower-case warnings
* [Tests] Replace module import with sys.modulesCalum Lind2014-09-19
|
* Sort/prettify imports with isortCalum Lind2014-09-03
|
* [Python-Modernize] libmodernize.fixes.fix_printCalum Lind2014-09-03
| | | | * Replaces print with print()
* refactor torrent.set_optionsCalum Lind2014-02-15
|
* Removed LoopingCall from torrent.pybendikro2013-11-21
| | | | | | Having a LoopingCall for each torrent is expencive with a lot of torrents. The LoopingCall in torrent.py has been moved to torrentmanager.py which runs through all the torrents and calls cleanup_prev_status.