384 Commits

Author SHA1 Message Date
Christopher Allan Webber
d3604e2920 Unit tests for plugins defining their own config_spec.ini!
This commit sponsored by David Ahmed.  Thank you!
2013-05-08 11:02:53 -05:00
Gabi Thume
98ce23d204 Fixing ticket #146 - Make messaging system testable 2013-04-29 20:35:22 -07:00
Elrond
3b359dddc7 image resizing: Refactor some decisions into resize_tool.
Loading the thumb/medium sizes from the config, saving
things to the db, and loading the image is now all done by
resize_tool. It still calls resize_image for the actual
work.
2013-04-27 17:19:50 +02:00
Elrond
d891966424 Unit test for ReallyLazyProxy.
LazyProxy caches its value. So create a unit test for
lazy_pass_to_ugettext to make sure its returned proxy
actually gives a different translation when the locale
is switched.
2013-04-25 14:31:29 +02:00
Elrond
fd1202b774 Cleanup storage after test, and test .delete_dir().
The storage tests work in the system's tmpdir. The python
docs say, we should clean up after using things.  Yes the
directory should be cleaned up on reboot, but if running
tests a lot, the tmpdir could fill up, so we should really
cleanup.

So use the new .delete_dir() on the storage interface to
cleanup test dirs and get them finally removed with
os.rmdir. All nicely packed into cleanup_storage().
2013-04-21 19:26:57 +02:00
Elrond
12dccc4552 Refactor test configs.
All the hook_* tests use the same config, so refactor it.
2013-04-20 00:24:09 +02:00
Christopher Allan Webber
97e0a79f39 Let's not use reserved keywords :) 2013-04-19 16:31:23 -05:00
Christopher Allan Webber
a0e7699a45 Added new tests to test hook_transform() 2013-04-19 16:28:41 -05:00
Christopher Allan Webber
d1146101bb Adjusting tests to use hook_handle and hook_runall 2013-04-19 16:16:26 -05:00
Christopher Allan Webber
2455a54f72 Moving the rest of the relevant tests to have test_app set up in "def setup()" as well 2013-04-18 11:15:47 -05:00
Christopher Allan Webber
0f3467013f at pytest author's advice, changing the way _setup back to -> setup
They showed me how to use @pytest.fixture, which allowed us to pass the
test into setup!
2013-04-18 10:53:36 -05:00
Elrond
f84425c0c1 Turning image's media manager into a new style class.
images are the first media type to use the new style class
based media manager.
2013-04-17 12:09:30 +02:00
Elrond
2077d6ed93 First step towards a MediaManager class: Compat one.
To get us moving towards a MediaManager class, the first
idea is to create a class that wraps our current dict based
manager and makes all users happy.
2013-04-17 12:08:52 +02:00
Alon Levy
d0e9f843e2 PIL: Support systems with Pillow and without
Fixes for systems with Pillow, but leaves a "try: except ImportError" to
support anything that doesn't have a PIL top level import.

Signed-off-by: Alon Levy <alon@pobox.com>
2013-04-17 12:54:54 +03:00
Elrond
b698c94d03 Refactor test resources into new resources.py 2013-04-17 01:15:46 +02:00
Elrond
54b3113abc PDF: Use pytest.mark.skipif for skipping tests
Instead of leaving test early if they can not run, use the
pytest.mark.skipif marked to tell the test system not to
even run the test.

This also adds to the stats, because skipped tests are
counted differently. Thus making it obvious, that some
tests did not run, because of any reason.
2013-04-16 23:39:01 +02:00
Elrond
d38e9779dd test_timesince() doesn't need a complete test_app. 2013-04-16 19:40:57 +02:00
Christopher Allan Webber
455f2d6506 Removing unused imports 2013-04-15 15:55:24 -05:00
Alon Levy
a80ebf3b64 add pdf media type
The new media type supports pdf and a subset of media recognized by libreoffice via
unoconv.

Every document added goes through:
* conversion to pdf with unoconv if not already a pdf
* creation of thumbnail and medium sized image, and pdfinfo generates
 some information (even for unoconv produces docs - should fix this)

Poppler (pdftocairo, pdfinfo) is used.  http://poppler.freedesktop.org/

A working but uglified pdf.js integration exists, which is enabled by
setting pdf.pdf_js=true mediagoblin_local.ini (disabled in mediagoblin.ini)

Adds one test to the test_submission test suite, and another separate test_pdf suite.
The tests are only run if media_types.pdf.processing.check_prerequisites passes, so
the test suite will not require any extra package.

TODO: make test suite say 'skipped' in that case instead of just 'ok'

Signed-off-by: Alon Levy <alon@pobox.com>
2013-04-15 09:51:21 +03:00
Nathan Yergler
64598a79a9 Merge remote-tracking branch 'joar-github/oauth/refresh_tokens'
This merges the patch for Issue #548.
2013-04-13 15:54:58 -07:00
Christopher Allan Webber
6432755db3 Merge remote-tracking branch 'refs/remotes/tsyesika/394-fuzzy-timestamp' 2013-04-13 11:42:34 -05:00
Jessica T
79e2d4eee4 Adds the unit tests and removes useless function we don't use 2013-04-12 01:40:15 +01:00
Christopher Allan Webber
761e26bb29 Merge branch '637_friendlier_hooks' 2013-04-10 17:53:05 -05:00
Christopher Allan Webber
cdc821eb74 callable hook convenience functions.. now work, and with tests!
- Added three "callables" test plugins.
 - updated callable_runone to check for unhandled_okay in the kwargs
   dict.

All passing!
2013-04-10 17:36:21 -05:00
Elrond
82a40cc4e1 Remove the last traces of beaker.
There were still some traces of beaker around:
- docs: replaced by reference to itsdangerous.
- paste configs: Wiped away.
- config_spec.ini: wiped.
- test_mgoblin_app.ini: also wiped.
2013-04-09 22:39:04 +02:00
Elrond
8021cc5605 Merge remote-tracking branch 'brett/itsdangerous'
* brett/itsdangerous:
  Call is_updated instead of testing it boolean.
  Harden It's Dangerous key management.
  First tests for the Session class.
  Set a starting value for session.send_new_cookie.
  Remove beaker stuff from the code.
  Delete the session cookie on an empty session.
  Back sessions with It's Dangerous.
  Improve fs security for itsdangerous secret.
  Docs for get_timed_signer_url.
  Basic itsdangerous infrastructure.

Conflicts:
	mediagoblin/tests/test_cache.py
2013-04-09 19:40:54 +02:00
Christopher Allan Webber
70c061955c tests for new pluginapi methods that can't possibly pass yet :) 2013-04-09 11:21:31 -05:00
Elrond
25067d8110 Testing: Remove some left over files/dirs.
When using tempfile.* in testing, those files get created
in the system tempdir. The docs say, we should try to
remove them.
Yes, the next reboot will clean them up also.

And in the workbench case, check after each test, that the
global workbench dir is empty (so the sub-workbcnhes have
been destroyed).
2013-04-08 17:03:26 +02:00
Joar Wandborg
c121a7d3d0 OAuth: Support refresh tokens, etc
Initially I was going to write a failing test for refresh tokens. Thus
this fix includes an orphaned 'expect_failure' method in test utils.

I ended up writing support for OAuth refresh tokens, as well as a lot of
cleanup (hopefully) in the OAuth plugin code.

**Rebase**: While waiting for this stuff to be merged, the testing
framework changed, it comes with batteries included regarding fails.
Removed legacy nosetest helper.

Also added a lot of backref=backref([...], cascade='all, delete-orphan')
2013-04-06 22:17:27 +02:00
Christopher Allan Webber
7d503a897b Really removing nosetests things now! all assert_whatever removed 2013-04-06 10:08:26 -05:00
Christopher Allan Webber
5c2ece7401 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
2013-04-04 19:23:04 -05:00
Christopher Allan Webber
e11c62a0ef Oops, forgot to assign dump_old_app to self, heh. 2013-04-04 11:13:47 -05:00
Christopher Allan Webber
245d4f119f Turning setup_fresh_app into SetupFreshApp, a decorator with options!
This way people can pass in particular paste/mediagoblin configs that they want to use.
2013-04-04 11:08:50 -05:00
Christopher Allan Webber
6588acc183 Updating get_app to allow for passing in particular app configs 2013-04-04 10:37:32 -05:00
Christopher Allan Webber
cb14544082 These tests need to have a MediaGoblin app setup so they can connect to the db!
Thanks to py.test --boxed for helping discover that ;)
2013-04-03 14:32:35 -05:00
Christopher Allan Webber
958080be16 All mediagoblin tests now pass with py.test (switched setUp to setup) 2013-04-03 14:05:42 -05:00
Brett Smith
e84e1cdf12 First tests for the Session class. 2013-03-24 15:46:10 -04:00
Brett Smith
9e1fa2396f Remove beaker stuff from the code.
This is all obsoleted by It's Dangerous.
2013-03-24 15:10:08 -04:00
Christopher Allan Webber
c56243f08c Changing "evil" submission test-script to be a bash script. 2013-03-12 21:36:12 -05:00
Elrond
df5b142ab9 Fix deleting media with attachments.
If one deletes a media with attachments, there have been
various problems:
1) If the file in the storage did not exist any more (maybe
   because due to a previous deletion attempt?), the error
   propagation failed, because the wrong thing was
   gathered.
2) The attachment database entries were not deleted.
   Using cascade for this, for now.

Also add a simple unit test, that tests both by having a
broken attachment on a media.
2013-02-18 14:55:42 +01:00
Elrond
d728c636b9 Some tests for media_data, yeah!
One in the submissions, that posts a jpg with gps data.
One in the modelmethods to test some behaviours.

The later test fails.
Fixes coming up.
2013-02-01 22:02:29 +01:00
Elrond
04453ccf42 Better Py3 compat: d.has_key(k) -> k in d
py3 does not have dict.has_key any more. You have to use
"key in dict" instead. As that works in python2 as well,
let's use that.

Also some small bits of pep8.
2013-01-30 15:03:04 +01:00
Elrond
3f931680e3 Improve runtime of one test.
Do not commit so often. flushing is enough.
2013-01-29 21:45:16 +01:00
Elrond
e9b4e50007 Failing testcase for issue 611.
This currently fails (with foreign key constrain error):
1. Have user A and B.
2. User B creates media M.
3. User A post a comment on M.
4. User A deletes his own account.

The test is a little bit wider.
2013-01-29 21:13:49 +01:00
Christopher Allan Webber
d5600aa75c Fix reference of get_test_app->get_app in test_modelmethods
(This changed in master while this test was being written; correcting
post-merge.)
2013-01-25 12:10:27 -06:00
Christopher Allan Webber
c7d135b6ea Merge branch '216_cwebber_style_unique_slugs' 2013-01-25 12:03:40 -06:00
Christopher Allan Webber
a81082fcaf New mediaentry slug tests now pass!
- fixed some issues with "whacking uuid junk on the slug"
 - uuid4() -> uuid.uuid4() so that mock will work right
 - added all the tests!
2013-01-23 16:49:54 -06:00
Sebastian Spaeth
a89df96132 Restructure ForgotPassword view
1) Remove mongo limitations (no 'or' when querying for either username
or email).

2) Lost password function revealed if an user name or email address
   is registered, which can be considered a data leak.
   Leaking user names is OK, they are public anyway, but don't reveal
   lookup success in case the lookup happened by email address.
   Simply respond: "If you have an account here, we have send you
                    your email"?

3) username and email search was case sensitive. Made username search
   case insensitive (they are always stored lowercase in the db).
   Keep email-address search case sensitive for now. This might need
   further discussion

4) Remove a whole bunch of indention in the style of:
   if no error:
        ...
        if no error:
            ...
            if no error:
                actually do something in the regular case

   by restructuring the function.

5) Outsource the sanity checking for username and email fields into the
   validator function. This way, we get automatic case sanity checking
   and sanitizing for all required fields.

6) Require 5-char password and fix tests

   Originally, the Change password form required a password between 6-30
   chars while the registration and login form did not require anything
   special. This commit introduces a common minimum limit for all forms
   which breaks the test suite which uses a 5 char password by
   default. :-).  As 5 chars seem sensible enough to enforce (people
   should be picking much longer ones anyway), just reduce the limit to
   5 chars, thereby making all tests pass.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-21 17:14:59 +01:00
Elrond
d92fbdc4ea Add (failing) test for editing the slug.
This test fails, because it tries to set a slug with an "="
in it. And tests that the "=" gets replaced by "-".

Well, it currently is not being replaced.

The next (cherry picked) commit by Sebastian Spaeth fixes
this test!
2013-01-18 21:21:42 +01:00
Elrond
cd75b2280f Add some simple collection test. 2013-01-18 11:42:56 +01:00