aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix deleting media with attachments.Elrond2013-02-181-0/+15
| | | | | | | | | | | | | | 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.
* Some tests for media_data, yeah!Elrond2013-02-012-1/+25
| | | | | | | | 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.
* Better Py3 compat: d.has_key(k) -> k in dElrond2013-01-302-22/+11
| | | | | | | | 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.
* Improve runtime of one test.Elrond2013-01-291-4/+10
| | | | Do not commit so often. flushing is enough.
* Failing testcase for issue 611.Elrond2013-01-292-2/+68
| | | | | | | | | | 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.
* Fix reference of get_test_app->get_app in test_modelmethodsChristopher Allan Webber2013-01-251-2/+2
| | | | | (This changed in master while this test was being written; correcting post-merge.)
* Merge branch '216_cwebber_style_unique_slugs'Christopher Allan Webber2013-01-251-0/+130
|\
| * New mediaentry slug tests now pass!Christopher Allan Webber2013-01-231-0/+130
| | | | | | | | | | | | - fixed some issues with "whacking uuid junk on the slug" - uuid4() -> uuid.uuid4() so that mock will work right - added all the tests!
* | Restructure ForgotPassword viewSebastian Spaeth2013-01-211-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Add (failing) test for editing the slug.Elrond2013-01-181-1/+7
| | | | | | | | | | | | | | | | | | | | 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!
* | Add some simple collection test.Elrond2013-01-182-1/+59
| |
* | Rename get_test_app to get_app.Elrond2013-01-1812-32/+32
| | | | | | | | | | | | | | nosetests runs everything that even vaguely looks like a test case... even our get_test_app. And as it is imported everywhere... it is run everywhere as a test case. Renaming it saves us about 10+ tests and a few seconds of time.
* | Move workbench into tools directory.Elrond2013-01-171-1/+1
| |
* | Merge commit '9408938' from 565_workbench_cleanup (spaetz)Christopher Allan Webber2013-01-171-8/+26
|\ \
| * | Add @get_workbench testSebastian Spaeth2013-01-161-2/+19
| | | | | | | | | | | | | | | | | | Test the decorator function and proper cleanup after it's usage. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
| * | Shorten Workbench(Manager) method namesSebastian Spaeth2013-01-161-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) destroy_self() is a horrible function name, make it "destroy". workbench.destroy() is descriptive enough. 2) WorkbenchManager.create_workbench() -> WorkbenchManager.create() We use the pattern "with workbench_manager.create() as workbench:" No need to mention workbenches three times in a row... Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | | Introduce user_deletion test.Sebastian Spaeth2013-01-171-0/+18
|/ / | | | | | | | | | | | | | | Delete a user via web interface and see if it works. TODO: this does not test that related entries are also cleaned up and we should extend the test to do so. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Merge remote-tracking branch 'refs/remotes/elrond/misc/use_media_id'Christopher Allan Webber2013-01-161-2/+8
|\ \ | |/ |/|
| * Start to use the media_id in "admin" URLs.Elrond2013-01-111-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | We have a bunch of URLs that are more for internal use. At least they're definitely not intended to be posted somewhere for long term useage. When those things affect a media, it's much better to reference the media by its id. This can't change, ever. This is better for races. Like someone posting a comment while the owner corrects a typo in the slug.
* | More explicit get_or_create patternSebastian Spaeth2013-01-151-1/+4
|/ | | | | | | | | Don't do "user = getUser() or newUser()" in one line. It is bound to confuse poor souls. Be more explicit here and even add a code comment. Thanks to Elrond for not liking the previous pattern. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Improve and extend profile editing testsSebastian Spaeth2013-01-091-76/+97
| | | | | | | | | | | | | | | | | | We only ever ran the password changing test here, and not the half-existing test for changing the bio and homepage. Fix the tests to actually run both tests. We check that setting bio and homepage to a valid value works as expected. We also test for invalid bio (too long) and invalid URLs setting fails. (which is what we want). - Check that the old /edit/profile/ address redirects to /u/USER/edit/. - Check that /u/USER/edit/ works as expected - Check that /u/OTHERUSER/edit/ fails with a 403 Forbidden error when we are not logged in as that user. The last remaining test that would be useful is to make a user an admin and make sure the admin can edit other users' profiles. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix tests on webtest < 1.3.6.Elrond2013-01-091-1/+5
| | | | | | | | | | | Debian testing ships webtest 1.3.4. And it would be nice to use the base packages. One of the csrf tests fails on webtest < 1.3.6. But using a fresh app fixes it. We have no clue, why exactly. When we require webtest 1.3.6, change this.
* Move db.sql.migration_tools to db.migration_tools.Elrond2013-01-081-1/+1
| | | | Follow the new trend.
* Move all the migration tools into new migration_tools.pyElrond2013-01-081-1/+1
| | | | | | | | | Factor all the migration related stuff out into a new .db.sql.migration_tools. First we don't have to load this module for our normal server. Second it makes all the import dependencies a little more cleaner.
* tests: More instances where a fresh database is not neededSebastian Spaeth2013-01-085-31/+27
| | | | Save test runtime by not dumping the databases when not needed.
* Don't get a fresh app when not neededSebastian Spaeth2013-01-084-14/+12
| | | | | | | | These tests, don't need fresh databases, so don't discard and recreate the tables. This reduces test suite runtime on my laptop from 130 to 96 seconds. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Do not fail is a user exists alreadySebastian Spaeth2013-01-081-3/+4
| | | | | | | | | When the tests want to create a new user, don't fail if it already exists and just reuse the existing one. This allows us to run tests without dumping the whole database if that is not needed for the tests. The upcoming tests for test_edit will make use of this. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Mv db.sql.base to db.baseSebastian Spaeth2013-01-072-3/+2
| | | | | | | | This concludes the db.sql.* -> db.* move. Our db abstraction layer is sqlalchemy, so there is no need to a separate db.sql.* hierarchy. All tests have been run for each of the commit series to make sure everything works at every step.
* Move db.sql.models* to db.models*Sebastian Spaeth2013-01-072-2/+2
|
* Move db.sql.util to db.utilSebastian Spaeth2013-01-071-1/+1
| | | | | | | | Now that sqlalchemy is providing the database abstractions, there is no need to hide everything in db.sql. sub-modules. It complicates the code and provides a futher layer of indirection. Move the db.sql.util.py to db.util.py and adapt the importers.
* Also make slug unit test work with the new optionally-translitcodec-free codeChristopher Allan Webber2013-01-061-7/+7
|
* Remove temporary emacs files that have slipped inSebastian Spaeth2012-12-252-275/+0
| | | | Thanks Elrond for hilighting this :-)
* RIP out mongoSebastian Spaeth2012-12-251-4/+1
| | | | | | | | | Since sqlalchemy is providing our database abstraction and we have moved away from Mongo as the underlying database, it is now time to simplify things and rip out mongo. This provides the bulk of the changes, and can stand on its own. There are some followup tasks that can be done, such as removing now unneeded abstraction layers, e.g. db.sql.fake.py
* Update extlib/EXIFSebastian Spaeth2012-12-253-15/+279
| | | | | | | | | | | | Bump bundled EXIF lib to 1.0.10 as release in Sep 2012. Also skip unused detailed EXIF tags for reading, we might turn that on when we need them. Adapt test to wording change in EXIF Flas field and due to the fact that we use "details=False" by default now (we did not use these anyway) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix some unicode related issues in oauth and the api.Elrond2012-12-231-1/+1
| | | | Found using the previous commit.
* Testsuite: Turn SQLAlchemy warnings into errorsElrond2012-12-231-0/+4
| | | | | | | | | | We should handle SQLAlchemy warnings. And to make that a lot easier, turn them into real errors. That way they 1) Turn up more prominently. 2) Have a useful backtrace. This only happens in the testsuite, so that normal useage is not impacted.
* Added API testsJoar Wandborg2012-12-232-0/+106
|
* replace webob.Response with werkzeug ResponseSebastian Spaeth2012-12-211-1/+1
| | | | | | | | | | | | Replace webob usage in one more file. Document a TODO that should be clarified, we should probably be using json_response rather than Response() here. Modify the TestMeddleware to not rely on the content_type attribute being present, while werkzeug.wrappers Response() has it the BaseResponse() object which is often returned in tests does not have it. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* tests/auth: Don't rely on case sensitive error stringsSebastian Spaeth2012-12-211-2/+2
| | | | | | | | | | webob's 404 status is "404 NOT FOUND" while werkzeug's is "404 Not Found". Our test suite was checking the upper case string for equality. Just test the status error code "404" rather than the full string which might change at some points/versions and should not need to be tested. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Move DBModel._id -> DBModel.idSebastian Spaeth2012-12-213-11/+11
| | | | | | | | | | | | | | | | | | | | | | | We were refering to model._id in most of the code base as this is what Mongo uses. However, each use of _id required a) fixup of queries: e.g. what we did in our find() and find_one() functions moving all '_id' to 'id'. It also required using AliasFields to make the ._id attribute available. This all means lots of superfluous fixing and transitioning in a SQL world. It will also not work in the long run. Much newer code already refers to the objects by model.id (e.g. in the oauth plugin), which will break with Mongo. So let's be honest, rip out the _id mongoism and live with .id as the one canonical way to address objects. This commit modifies all users and providers of model._id to use model.id instead. This patch works with or without Mongo removed first, but will break Mongo usage (even more than before) I have not bothered to fixup db.mongo.* and db.sql.convert (which converts from Mongo to SQL) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix up testsSebastian Spaeth2012-12-213-11/+13
| | | | | | | | | | | | empty find() queries would not work anymore with the simplified .find compatability code, so remove these and use proper sqlalchemy in the tests. The storage test failed because my virtualenv environment ran mediagoblin/local/mediagoblin/tests/test_storage.py and somehow decided the 2 classes are different objects. Just test against the full class name. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* More unicode fixes in the test suiteSebastian Spaeth2012-12-121-6/+7
| | | | | | | | | | Pass in unicode not (binary) strings where sqlite expects unicode values to prevent the test suite from (correctly) complaining about errors. I now pass the full suite without any complaints. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Make sqlalchemy stop complaining about non-unicode inputSebastian Spaeth2012-12-112-4/+4
| | | | | | | | | | | These tests output noisy sql complaints about receiving non-unicode for an unicode field. This was ... well ... because we were handing in non-unicode usernames and passwords. Prefixing usernames/passwords with u'' makes the testsuite less noisy and verbose. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix CSRF tests with webtest 1.4.0Sebastian Spaeth2012-12-111-3/+3
| | | | | | | | | | CSRF tests apparently passed with earlier versions of webtest, but failed with the latest webtest (1.4.0) package. It choked on passing a "key=value; " cookie as it split at the semicolon and failed to find additional values or something like that. Removing the semicolon makes this test pass. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Add a UniqueConstraint add test in test_sql_migrationsChristopher Allan Webber2012-12-051-3/+26
| | | | | We should have this anyway, and Elrond needs it to help fix current broken migration thingies.
* make media_manager a property of MediaEntry in mixin.pySebastian Spaeth2012-12-041-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | In all cases where get_media_manager(_media_type_as_string) was called in our code base we ultimately passed in a "MediaEntry().media_type" to get the matching MEDIA_MANAGER. It so makes sense to make this a function of the MediaEntry rather than a global function in mediagoblin.media_types and passing around media_entry.media_type as arguments all the time. It saves a few import statements and arguments. I also made it so the Media_manager property is cached for subsequent calls, although I am not too sure that this is needed (there are other cases for which this would make more sense) Also add a get_media_manager test to the media submission tests. It submits an image and checks that both media.media_type and media.media_manager return the right thing. Not sure if these tests could not be merged with an existing submission test, but it can't hurt to have things explicit. TODO: Right now we iterate through all existing media_managers to find the right one based on the string of its module name. This should be made a simple dict lookup to avoid all the extra work. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fixed pylint issues, removed unused importJoar Wandborg2012-10-021-1/+1
|
* Replaced all request.POST with request.form, ...Joar Wandborg2012-09-291-8/+17
| | | | | - Fixed error handling in OAuth plugin - Changed request.POST file fields to request.files
* Added OAuth testJoar Wandborg2012-09-291-0/+50
|
* Fixed pylint/pep8 warnings in test/tools.pyJoar Wandborg2012-09-291-2/+2
|