From cd75b2280fc2fe953bf1158ec1b9d5fb0d43a881 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 18 Jan 2013 11:42:56 +0100 Subject: Add some simple collection test. --- mediagoblin/tests/test_collections.py | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 mediagoblin/tests/test_collections.py (limited to 'mediagoblin/tests/test_collections.py') diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py new file mode 100644 index 00000000..b19f6362 --- /dev/null +++ b/mediagoblin/tests/test_collections.py @@ -0,0 +1,37 @@ +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2013 MediaGoblin contributors. See AUTHORS. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user, \ + get_app +from mediagoblin.db.models import Collection, User +from mediagoblin.db.base import Session +from nose.tools import assert_equal + + +def test_user_deletes_collection(): + # Setup db. + get_app(dump_old_app=False) + + user = fixture_add_user() + coll = fixture_add_collection(user=user) + # Reload into session: + user = User.query.get(user.id) + + cnt1 = Collection.query.count() + user.delete() + cnt2 = Collection.query.count() + + assert_equal(cnt1, cnt2 + 1) -- cgit v1.2.3 From 5c2ece7401723486d76ea0fcd2f99ba4d1002504 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 4 Apr 2013 19:23:04 -0500 Subject: Switch test_app generation over to use py.test fixtures. By doing this, we can take advantage of py.test's ability to create temporary directories that are then cleaned up later during testing. This helps for sandboxing things. This also involves a ton of changes: - Changing the get_app stuff appropriately, getting rid of the setup_fresh_app decorator - Making said fixture - Switching over a billion tests to use it --- mediagoblin/tests/test_collections.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'mediagoblin/tests/test_collections.py') diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py index b19f6362..d4d3af71 100644 --- a/mediagoblin/tests/test_collections.py +++ b/mediagoblin/tests/test_collections.py @@ -14,17 +14,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user, \ - get_app +from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user from mediagoblin.db.models import Collection, User -from mediagoblin.db.base import Session from nose.tools import assert_equal -def test_user_deletes_collection(): +def test_user_deletes_collection(test_app): # Setup db. - get_app(dump_old_app=False) - user = fixture_add_user() coll = fixture_add_collection(user=user) # Reload into session: -- cgit v1.2.3 From 7d503a897bddfadcd98d278bdb648503485a19de Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sat, 6 Apr 2013 10:07:47 -0500 Subject: Really removing nosetests things now! all assert_whatever removed --- mediagoblin/tests/test_collections.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mediagoblin/tests/test_collections.py') diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py index d4d3af71..87782f30 100644 --- a/mediagoblin/tests/test_collections.py +++ b/mediagoblin/tests/test_collections.py @@ -16,7 +16,6 @@ from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user from mediagoblin.db.models import Collection, User -from nose.tools import assert_equal def test_user_deletes_collection(test_app): @@ -30,4 +29,4 @@ def test_user_deletes_collection(test_app): user.delete() cnt2 = Collection.query.count() - assert_equal(cnt1, cnt2 + 1) + assert cnt1 == cnt2 + 1 -- cgit v1.2.3 From 0536306048daa0970d2e43411ba2a9bf073e570e Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 16 May 2013 17:51:21 -0500 Subject: Always activate testing in every test module ever. Kind of a dorky way to implement this, but... --- mediagoblin/tests/test_collections.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mediagoblin/tests/test_collections.py') diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py index 87782f30..42f0cc4c 100644 --- a/mediagoblin/tests/test_collections.py +++ b/mediagoblin/tests/test_collections.py @@ -17,6 +17,9 @@ from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user from mediagoblin.db.models import Collection, User +from mediagoblin.tools.testing import _activate_testing +_activate_testing() + def test_user_deletes_collection(test_app): # Setup db. -- cgit v1.2.3 From 9a9bafc078192317695a4f06233ea261fe147989 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 17 May 2013 11:12:56 -0500 Subject: Reverting "Always activate testing in every test module ever." Revert "Always activate testing in every test module ever." This reverts commit 0536306048daa0970d2e43411ba2a9bf073e570e. --- mediagoblin/tests/test_collections.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'mediagoblin/tests/test_collections.py') diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py index 42f0cc4c..87782f30 100644 --- a/mediagoblin/tests/test_collections.py +++ b/mediagoblin/tests/test_collections.py @@ -17,9 +17,6 @@ from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user from mediagoblin.db.models import Collection, User -from mediagoblin.tools.testing import _activate_testing -_activate_testing() - def test_user_deletes_collection(test_app): # Setup db. -- cgit v1.2.3