summaryrefslogtreecommitdiff
path: root/tests/helper_test.py
Commit message (Collapse)AuthorAge
* Rename test filesLucas Hoffmann2019-01-29
| | | | | | | | The two main reasons are - to run `python3 -m unittest discover` without specifying a custom `--pattern *_test.py` - to include the test files automatically when generating the MANIFEST file.
* tests: Require python3 in test_env_setJordan Justen2018-12-19
| | | | | Fixes: https://github.com/pazz/alot/issues/1354 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
* Fix deprecation warnings for unittestsLucas Hoffmann2018-11-11
|
* helper: replace email_as_* with email builtinsDylan Baker2018-08-02
| | | | | | | | | | | | | | Python 3.3 added a new feature to the email module, policies (https://docs.python.org/3.5/library/email.policy.html). Policy objects allow precise control over how numerous features work when converting to and from str or bytes. With the `email.policy.SMTP` the behavior of email_as_bytes and email_as_string can be achieved using the builtin `.as_string()` and `.as_bytes()` methods, without custom code or the need to test it. Additionally these methods handle corner cases that we don't currently handle, such as multi-part messages with different encodings. Fixes #1257
* tests: drop remaining references to twisted from unit testsDylan Baker2018-07-26
| | | | all unittests now use asyncio and the standard unittest framework.
* helper: use asyncio.subprocess instead of twistedDylan Baker2018-07-26
|
* Add simple test case for helper.parse_mailtoJohannes Löthberg2018-07-16
| | | | Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
* Remove old __future__ importsLucas Hoffmann2018-06-19
| | | | They are not needed for python >= 3.0.
* helper: py3k fixesDylan Baker2018-03-01
|
* replace xrange with rangeDylan Baker2018-03-01
| | | | In python 3 xrange is range, to get a list one must wrap range in list.
* Set changed values in mock.patch.dict call itself.Julian Mehne2018-01-23
|
* Rename get_env to get_xdg_env and clarify docstring.Julian Mehne2018-01-23
|
* Fix empty XDG_* environment variables.Julian Mehne2018-01-21
| | | | | | | | | | | | Use fallback, if an enviroment variable is unset *or* empty. Bug: - XDG_CONFIG_HOME='' alot Problem: Does not find the configuration file (among others), because os.environ.get('XDG_CONFIG_HOME', '~/.config') returns '', instead of '~/.config'.
* alot/helper: Fix call_cmd_async polluting global environmentDylan Baker2017-08-22
| | | | | | | | | | An assignment `e = os.environ` creates a reference not a copy, which means that modifying one necessarily modifies the other. Using `dict.copy` creates a shallow copy (the keys and values are references, but the dicts are different objects), which means only modifications to mutable objects are shared. In the case of os.environ which only contains immutable objects like strings, bools, and numbers this isn't an issue.
* tests/helper: Add tests for call_cmd_asyncDylan Baker2017-08-22
|
* tests/helper_test.py: Add tests for helper.shortenDylan Baker2017-08-22
|
* Use cStringIO.StringIO to fix #1132Lucas Hoffmann2017-08-21
| | | | | | | | | This undoes a small subset of the changes from fa3dd1b04567c4ea03fa658c3838b569531c79f5 and thus fixes #1132. The io.BytesIO object was not able to handle the unicode header names that where returned by envelope.construct_mail, which in turn did just copy them from the envelope header.
* Add failing test for alot.helper.email_as_string()Lucas Hoffmann2017-08-21
| | | | | Since email_as_string uses io.BytesIO it can not handle the unicode header names that might result from a envelope.construct_mail().
* tests/helper_test.py: Don't use GNU %P, which breaks non glibc platformsDylan Baker2017-05-30
| | | | | | Instead us %p, which differs only in the case of the am/pm. Fixes #1048
* Move Popen.communicate call out of try-except blockLucas Hoffmann2017-02-19
| | | | | The OSError that is being caught should only be raised by the Popen constructor: https://docs.python.org/3/library/subprocess.html#exceptions
* Add tests for OSError handling in alot.helper.call_cmdLucas Hoffmann2017-02-18
|
* alot/helper: simplify call_cmd and fix testDylan Baker2017-02-07
| | | | | This both fixes a test that failed (since stderr wasn't being set) and simplifies the function to only have one path that uses a ternary.
* tests/helper_test.py: Add tests for call_cmdDylan Baker2017-02-07
| | | | This even finds a bug!
* helper: Use kibi and mibibytes instead of kilo and megabytesDylan Baker2017-01-27
| | | | | | | | | | | | Technically a kilobyte (and it's derivatives like megabytes and gigabytes) are defined as powers of 1000, while a kibibyte (and it's derivatives like mibibytes and gibibytes) are defined as powers of 1024. This patch fixes incorrect language and formatting in the humanize_size function which defined a kilobyte as 1024. See this wikipedia article for more information: https://en.wikipedia.org/wiki/Kibibyte
* tests: Implement tests for the helper moduleDylan Baker2017-01-24
| | | | | | | This doesn't implement complete coverage by any stretch, but it does implement a number of tests for the helper module, including a few for cases that are not handled correctly. These cases are marked as expected failures.
* Use absolute_imports from __future__Lucas Hoffmann2017-01-18
|
* Port old doctests to unittest: alot.helper.shorten_author_string()Lucas Hoffmann2017-01-18