diff --git a/.gitignore b/.gitignore index 17540ecfe..09dd6a368 100644 --- a/.gitignore +++ b/.gitignore @@ -18,9 +18,9 @@ static/default/plugins/ *.swo .vagrant .coverage -testing/tmp -testing/gpg-keyring/random_seed +mailpile/tests/data/tmp +mailpile/tests/data/gpg-keyring/random_seed ghostdriver.log cover/ bower_components/ -node_modules/ \ No newline at end of file +node_modules/ diff --git a/Makefile b/Makefile index ef3bdf24a..420fedf85 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ web: less js @true alltests: clean pytests - @chmod go-rwx testing/gpg-keyring + @chmod go-rwx mailpile/tests/data/gpg-keyring @python2 scripts/mailpile-test.py || true @nosetests @@ -85,11 +85,19 @@ pytests: @echo clean: - @rm -f `find . -name \\*.pyc` mailpile-tmp.py mailpile.py - @rm -f `find . -name \\*.mo` - @rm -f .appver MANIFEST setup.cfg .SELF .*deps - @rm -f scripts/less-compiler.mk - @rm -rf *.egg-info build/ mp-virtualenv/ dist/ testing/tmp/ + @rm -f `find . -name \\*.pyc` \ + `find . -name \\*.mo` \ + mailpile-tmp.py mailpile.py \ + .appver MANIFEST setup.cfg .SELF .*deps \ + scripts/less-compiler.mk + @rm -rf *.egg-info build/ mp-virtualenv/ dist/ \ + mailpile/tests/data/tmp/ testing/tmp/ + +sdist: clean + @python setup.py sdist + +bdist: compilemessages + @python setup.py bdist virtualenv: virtualenv -p python2 mp-virtualenv diff --git a/tests/TESTS b/mailpile/tests/TESTS similarity index 100% rename from tests/TESTS rename to mailpile/tests/TESTS diff --git a/tests/__init__.py b/mailpile/tests/__init__.py similarity index 88% rename from tests/__init__.py rename to mailpile/tests/__init__.py index 7e9b50b2c..35022b735 100644 --- a/tests/__init__.py +++ b/mailpile/tests/__init__.py @@ -22,7 +22,7 @@ def get_mailpile_root(): - return os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) TAGS = { 'New': { @@ -74,15 +74,16 @@ def get_shared_mailpile(): sys.stderr.write('Preparing shared Mailpile test environment, ' 'please wait. 8-)\n') + rootdir = get_mailpile_root() + datadir = os.path.join(rootdir, 'mailpile', 'tests', 'data') + gpgdir = os.path.join(datadir, 'gpg-keyring') + tmpdir = os.path.join(datadir, 'tmp') + test_data = os.path.join(datadir, 'Maildir') + # force usage of test keyring whenever the test mailpile instance is used - os.chmod(os.path.join(get_mailpile_root(), 'testing', 'gpg-keyring'), - stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR) + os.chmod(gpgdir, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR) global GNUPG_HOMEDIR - GNUPG_HOMEDIR = os.path.join(get_mailpile_root(), 'testing', 'gpg-keyring') - - workdir = get_mailpile_root() - tmpdir = os.path.join(workdir, 'testing', 'tmp') - test_data = os.path.join(workdir, 'testing', 'Maildir') + GNUPG_HOMEDIR = gpgdir if os.path.exists(tmpdir): shutil.rmtree(tmpdir) diff --git a/testing/Maildir/cur/.gitignore b/mailpile/tests/data/Maildir/cur/.gitignore similarity index 100% rename from testing/Maildir/cur/.gitignore rename to mailpile/tests/data/Maildir/cur/.gitignore diff --git a/testing/Maildir/cur/1379857166.25979_1.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25979_1.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25979_1.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25979_1.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25979_3.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25979_3.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25979_3.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25979_3.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25979_5.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25979_5.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25979_5.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25979_5.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25979_7.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25979_7.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25979_7.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25979_7.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25979_9.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25979_9.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25979_9.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25979_9.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25980_9.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25980_9.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25980_9.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25980_9.hottie,2,S diff --git a/testing/Maildir/cur/1379857166.25981_10.hottie,2,S b/mailpile/tests/data/Maildir/cur/1379857166.25981_10.hottie,2,S similarity index 100% rename from testing/Maildir/cur/1379857166.25981_10.hottie,2,S rename to mailpile/tests/data/Maildir/cur/1379857166.25981_10.hottie,2,S diff --git a/testing/Maildir/cur/broken_email_1396694612 b/mailpile/tests/data/Maildir/cur/broken_email_1396694612 similarity index 100% rename from testing/Maildir/cur/broken_email_1396694612 rename to mailpile/tests/data/Maildir/cur/broken_email_1396694612 diff --git a/testing/Maildir/cur/mailpile-1398950855.mbx b/mailpile/tests/data/Maildir/cur/mailpile-1398950855.mbx similarity index 100% rename from testing/Maildir/cur/mailpile-1398950855.mbx rename to mailpile/tests/data/Maildir/cur/mailpile-1398950855.mbx diff --git a/testing/Maildir/cur/mailpile-1400069992.mbx b/mailpile/tests/data/Maildir/cur/mailpile-1400069992.mbx similarity index 100% rename from testing/Maildir/cur/mailpile-1400069992.mbx rename to mailpile/tests/data/Maildir/cur/mailpile-1400069992.mbx diff --git a/testing/Maildir/new/.gitignore b/mailpile/tests/data/Maildir/new/.gitignore similarity index 100% rename from testing/Maildir/new/.gitignore rename to mailpile/tests/data/Maildir/new/.gitignore diff --git a/testing/Maildir/tmp/.gitignore b/mailpile/tests/data/Maildir/tmp/.gitignore similarity index 100% rename from testing/Maildir/tmp/.gitignore rename to mailpile/tests/data/Maildir/tmp/.gitignore diff --git a/testing/contacts/README b/mailpile/tests/data/contacts/README similarity index 100% rename from testing/contacts/README rename to mailpile/tests/data/contacts/README diff --git a/testing/contacts/contacttest.ldif b/mailpile/tests/data/contacts/contacttest.ldif similarity index 100% rename from testing/contacts/contacttest.ldif rename to mailpile/tests/data/contacts/contacttest.ldif diff --git a/testing/contacts/contacttest.mork b/mailpile/tests/data/contacts/contacttest.mork similarity index 100% rename from testing/contacts/contacttest.mork rename to mailpile/tests/data/contacts/contacttest.mork diff --git a/testing/contacts/contacttest.vcf b/mailpile/tests/data/contacts/contacttest.vcf similarity index 100% rename from testing/contacts/contacttest.vcf rename to mailpile/tests/data/contacts/contacttest.vcf diff --git a/testing/gpg-keyring/pubring.gpg b/mailpile/tests/data/gpg-keyring/pubring.gpg similarity index 100% rename from testing/gpg-keyring/pubring.gpg rename to mailpile/tests/data/gpg-keyring/pubring.gpg diff --git a/testing/gpg-keyring/secring.gpg b/mailpile/tests/data/gpg-keyring/secring.gpg similarity index 100% rename from testing/gpg-keyring/secring.gpg rename to mailpile/tests/data/gpg-keyring/secring.gpg diff --git a/testing/gpg-keyring/testing.gpg.pub b/mailpile/tests/data/gpg-keyring/testing.gpg.pub similarity index 100% rename from testing/gpg-keyring/testing.gpg.pub rename to mailpile/tests/data/gpg-keyring/testing.gpg.pub diff --git a/testing/gpg-keyring/trustdb.gpg b/mailpile/tests/data/gpg-keyring/trustdb.gpg similarity index 100% rename from testing/gpg-keyring/trustdb.gpg rename to mailpile/tests/data/gpg-keyring/trustdb.gpg diff --git a/testing/pgp-data/buildexamples.py b/mailpile/tests/data/pgp-data/buildexamples.py similarity index 100% rename from testing/pgp-data/buildexamples.py rename to mailpile/tests/data/pgp-data/buildexamples.py diff --git a/testing/pgp-data/sources/ar.iso-8859-6 b/mailpile/tests/data/pgp-data/sources/ar.iso-8859-6 similarity index 100% rename from testing/pgp-data/sources/ar.iso-8859-6 rename to mailpile/tests/data/pgp-data/sources/ar.iso-8859-6 diff --git a/testing/pgp-data/sources/ar.utf-8 b/mailpile/tests/data/pgp-data/sources/ar.utf-8 similarity index 100% rename from testing/pgp-data/sources/ar.utf-8 rename to mailpile/tests/data/pgp-data/sources/ar.utf-8 diff --git a/testing/pgp-data/sources/ar.windows-1256 b/mailpile/tests/data/pgp-data/sources/ar.windows-1256 similarity index 100% rename from testing/pgp-data/sources/ar.windows-1256 rename to mailpile/tests/data/pgp-data/sources/ar.windows-1256 diff --git a/testing/pgp-data/sources/cn.utf-8 b/mailpile/tests/data/pgp-data/sources/cn.utf-8 similarity index 100% rename from testing/pgp-data/sources/cn.utf-8 rename to mailpile/tests/data/pgp-data/sources/cn.utf-8 diff --git a/testing/pgp-data/sources/gr.iso-8859-7 b/mailpile/tests/data/pgp-data/sources/gr.iso-8859-7 similarity index 100% rename from testing/pgp-data/sources/gr.iso-8859-7 rename to mailpile/tests/data/pgp-data/sources/gr.iso-8859-7 diff --git a/testing/pgp-data/sources/gr.utf-8 b/mailpile/tests/data/pgp-data/sources/gr.utf-8 similarity index 100% rename from testing/pgp-data/sources/gr.utf-8 rename to mailpile/tests/data/pgp-data/sources/gr.utf-8 diff --git a/testing/pgp-data/sources/gr.windows-1253 b/mailpile/tests/data/pgp-data/sources/gr.windows-1253 similarity index 100% rename from testing/pgp-data/sources/gr.windows-1253 rename to mailpile/tests/data/pgp-data/sources/gr.windows-1253 diff --git a/testing/pgp-data/sources/ru.koi8-ru b/mailpile/tests/data/pgp-data/sources/ru.koi8-ru similarity index 100% rename from testing/pgp-data/sources/ru.koi8-ru rename to mailpile/tests/data/pgp-data/sources/ru.koi8-ru diff --git a/testing/pgp-data/sources/ru.utf-8 b/mailpile/tests/data/pgp-data/sources/ru.utf-8 similarity index 100% rename from testing/pgp-data/sources/ru.utf-8 rename to mailpile/tests/data/pgp-data/sources/ru.utf-8 diff --git a/testing/pgp-data/sources/ru.windows-1251 b/mailpile/tests/data/pgp-data/sources/ru.windows-1251 similarity index 100% rename from testing/pgp-data/sources/ru.windows-1251 rename to mailpile/tests/data/pgp-data/sources/ru.windows-1251 diff --git a/testing/pgp-data/sources/vi.utf-8 b/mailpile/tests/data/pgp-data/sources/vi.utf-8 similarity index 100% rename from testing/pgp-data/sources/vi.utf-8 rename to mailpile/tests/data/pgp-data/sources/vi.utf-8 diff --git a/testing/pub.key b/mailpile/tests/data/pub.key similarity index 100% rename from testing/pub.key rename to mailpile/tests/data/pub.key diff --git a/testing/tests.mbx b/mailpile/tests/data/tests.mbx similarity index 100% rename from testing/tests.mbx rename to mailpile/tests/data/tests.mbx diff --git a/tests/gui/__init__.py b/mailpile/tests/gui/__init__.py similarity index 99% rename from tests/gui/__init__.py rename to mailpile/tests/gui/__init__.py index eab552f58..386562d66 100644 --- a/tests/gui/__init__.py +++ b/mailpile/tests/gui/__init__.py @@ -9,7 +9,7 @@ pass from mailpile.httpd import HttpWorker -from tests import MailPileUnittest, get_shared_mailpile +from mailpile.tests import MailPileUnittest, get_shared_mailpile from mailpile.safe_popen import MakePopenUnsafe diff --git a/tests/gui/test_contacts.py b/mailpile/tests/gui/test_contacts.py similarity index 91% rename from tests/gui/test_contacts.py rename to mailpile/tests/gui/test_contacts.py index 04f0896ce..b389197ba 100644 --- a/tests/gui/test_contacts.py +++ b/mailpile/tests/gui/test_contacts.py @@ -1,4 +1,4 @@ -from tests.gui import MailpileSeleniumTest +from mailpile.tests.gui import MailpileSeleniumTest class ContactsGuiTest(MailpileSeleniumTest): diff --git a/tests/gui/test_mail.py b/mailpile/tests/gui/test_mail.py similarity index 92% rename from tests/gui/test_mail.py rename to mailpile/tests/gui/test_mail.py index 651182a5d..536f7469f 100644 --- a/tests/gui/test_mail.py +++ b/mailpile/tests/gui/test_mail.py @@ -1,4 +1,4 @@ -from tests.gui import MailpileSeleniumTest +from mailpile.tests.gui import MailpileSeleniumTest class MailGuiTest(MailpileSeleniumTest): diff --git a/tests/gui/test_tags.py b/mailpile/tests/gui/test_tags.py similarity index 96% rename from tests/gui/test_tags.py rename to mailpile/tests/gui/test_tags.py index 29971ec91..b5f05b6a3 100644 --- a/tests/gui/test_tags.py +++ b/mailpile/tests/gui/test_tags.py @@ -3,7 +3,7 @@ except ImportError: pass -from tests.gui import MailpileSeleniumTest +from mailpile.tests.gui import MailpileSeleniumTest class TagGuiTest(MailpileSeleniumTest): diff --git a/tests/test_command.py b/mailpile/tests/test_command.py similarity index 96% rename from tests/test_command.py rename to mailpile/tests/test_command.py index 1c5e34fac..9f14d9782 100644 --- a/tests/test_command.py +++ b/mailpile/tests/test_command.py @@ -1,9 +1,10 @@ import unittest -import mailpile +import os from mock import patch -from mailpile.commands import Action as action -from tests import MailPileUnittest +import mailpile +from mailpile.commands import Action as action +from mailpile.tests import MailPileUnittest class TestCommands(MailPileUnittest): @@ -31,11 +32,11 @@ def test_unset(self): self.assertEqual(results.result['stats']['count'], 3) def test_add(self): - res = self.mp.add("tests") + res = self.mp.add("scripts") self.assertEqual(res.as_dict()["result"], True) def test_add_mailbox_already_in_pile(self): - res = self.mp.add("tests") + res = self.mp.add("scripts") self.assertEqual(res.as_dict()["result"], True) def test_add_mailbox_no_such_directory(self): @@ -146,7 +147,7 @@ def test_key_receive(self): def test_key_import(self): res = action(self.mp._session, "crypto/gpg/importkey", - 'testing/pub.key') + os.path.join('mailpile', 'tests', 'data', 'pub.key')) self.assertEqual(res.result["results"]["count"], 1) def test_nicknym_get_key(self): diff --git a/tests/test_config.py b/mailpile/tests/test_config.py similarity index 99% rename from tests/test_config.py rename to mailpile/tests/test_config.py index 4d543292d..76e67d84b 100644 --- a/tests/test_config.py +++ b/mailpile/tests/test_config.py @@ -3,7 +3,7 @@ import mailpile from nose.tools import raises -from tests import MailPileUnittest +from mailpile.tests import MailPileUnittest class TestConfig(MailPileUnittest): diff --git a/tests/test_crypto_policy.py b/mailpile/tests/test_crypto_policy.py similarity index 98% rename from tests/test_crypto_policy.py rename to mailpile/tests/test_crypto_policy.py index 8c6ab0e49..4e8a88df8 100644 --- a/tests/test_crypto_policy.py +++ b/mailpile/tests/test_crypto_policy.py @@ -1,5 +1,5 @@ from mailpile.vcard import MailpileVCard, VCardLine -from tests import MailPileUnittest +from mailpile.tests import MailPileUnittest VCARD_CRYPTO_POLICY = 'X-MAILPILE-CRYPTO-POLICY' diff --git a/tests/test_eventlog.py b/mailpile/tests/test_eventlog.py similarity index 96% rename from tests/test_eventlog.py rename to mailpile/tests/test_eventlog.py index 113506172..b7430a2c4 100644 --- a/tests/test_eventlog.py +++ b/mailpile/tests/test_eventlog.py @@ -7,13 +7,13 @@ import time from nose.tools import raises -from tests import MailPileUnittest +from mailpile.tests import MailPileUnittest EVENT_ID_RE = re.compile("[a-f0-9]{8}\.[a-f0-9]{5}\.[a-f0-9]+") -mailpile_root = os.path.join(os.path.dirname(__file__), "..") -mailpile_tmp = os.path.join(mailpile_root, "testing/tmp") +mailpile_root = os.path.join(os.path.dirname(__file__), "..", "..") +mailpile_tmp = os.path.join(mailpile_root, "mailpile", "tests", "data", "tmp") class TestEventlog(MailPileUnittest): diff --git a/tests/test_keylookup.py b/mailpile/tests/test_keylookup.py similarity index 96% rename from tests/test_keylookup.py rename to mailpile/tests/test_keylookup.py index 2374ca119..629ad63b6 100644 --- a/tests/test_keylookup.py +++ b/mailpile/tests/test_keylookup.py @@ -1,8 +1,8 @@ from mock import patch -from tests import MailPileUnittest import datetime -from tests import get_shared_mailpile +from mailpile.tests import MailPileUnittest +from mailpile.tests import get_shared_mailpile from mailpile.plugins.keylookup import lookup_crypto_keys, KeyserverLookupHandler from mailpile.plugins.keylookup.email_keylookup import * diff --git a/tests/test_performance.py b/mailpile/tests/test_performance.py similarity index 92% rename from tests/test_performance.py rename to mailpile/tests/test_performance.py index 5f49fc9e2..14bd96475 100644 --- a/tests/test_performance.py +++ b/mailpile/tests/test_performance.py @@ -1,7 +1,7 @@ import unittest from nose.tools import assert_equal, assert_less -from tests import get_shared_mailpile, MailPileUnittest +from mailpile.tests import get_shared_mailpile, MailPileUnittest def checkSearch(postinglist_kb, query): diff --git a/tests/test_plugin.py b/mailpile/tests/test_plugin.py similarity index 98% rename from tests/test_plugin.py rename to mailpile/tests/test_plugin.py index b37da308a..e91c6a561 100644 --- a/tests/test_plugin.py +++ b/mailpile/tests/test_plugin.py @@ -1,7 +1,7 @@ import shutil import os from os import path -from tests import MailPileUnittest +from mailpile.tests import MailPileUnittest import json diff --git a/tests/test_search.py b/mailpile/tests/test_search.py similarity index 97% rename from tests/test_search.py rename to mailpile/tests/test_search.py index 083a785c5..8f0ac2c8f 100644 --- a/tests/test_search.py +++ b/mailpile/tests/test_search.py @@ -1,7 +1,7 @@ import unittest from nose.tools import assert_equal, assert_less -from tests import get_shared_mailpile +from mailpile.tests import get_shared_mailpile def checkSearch(query, expected_count=1): diff --git a/tests/test_ui.py b/mailpile/tests/test_ui.py similarity index 98% rename from tests/test_ui.py rename to mailpile/tests/test_ui.py index 0208f8193..b2abd3f1d 100644 --- a/tests/test_ui.py +++ b/mailpile/tests/test_ui.py @@ -2,7 +2,7 @@ import mailpile from mailpile.ui import UserInteraction -from tests import capture, MailPileUnittest +from mailpile.tests import capture, MailPileUnittest class TestUI(MailPileUnittest): diff --git a/tests/test_vcard.py b/mailpile/tests/test_vcard.py similarity index 98% rename from tests/test_vcard.py rename to mailpile/tests/test_vcard.py index 12313e534..6b39992f1 100644 --- a/tests/test_vcard.py +++ b/mailpile/tests/test_vcard.py @@ -1,7 +1,7 @@ import unittest import mailpile -from tests import MailPileUnittest +from mailpile.tests import MailPileUnittest class TestVCard(MailPileUnittest): diff --git a/scripts/mailpile-test.py b/scripts/mailpile-test.py index c634dc2a8..05369ccb0 100755 --- a/scripts/mailpile-test.py +++ b/scripts/mailpile-test.py @@ -14,7 +14,7 @@ # Set up some paths mailpile_root = os.path.join(os.path.dirname(__file__), '..') -mailpile_test = os.path.join(mailpile_root, 'testing') +mailpile_test = os.path.join(mailpile_root, 'mailpile', 'tests', 'data') mailpile_send = os.path.join(mailpile_root, 'scripts', 'test-sendmail.sh') mailpile_home = os.path.join(mailpile_test, 'tmp') mailpile_gpgh = os.path.join(mailpile_test, 'gpg-keyring') diff --git a/scripts/test-sendmail.sh b/scripts/test-sendmail.sh index 480a929eb..647d87278 100755 --- a/scripts/test-sendmail.sh +++ b/scripts/test-sendmail.sh @@ -1,5 +1,5 @@ #!/bin/bash -OUTPUT="$(dirname $0)/../testing/tmp/sent.mbx" +OUTPUT="$(dirname $0)/../mailpile/tests/data/tmp/sent.mbx" mkdir -p "$(dirname $OUTPUT)" touch "$OUTPUT" if [ -f "$OUTPUT" ]; then diff --git a/testing-data b/testing-data new file mode 120000 index 000000000..a0df316bd --- /dev/null +++ b/testing-data @@ -0,0 +1 @@ +mailpile/tests/data/ \ No newline at end of file