Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc Updates #7

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9599a29
Ignoring *.pyc
Mar 27, 2013
11b347a
Fixed naming of suite to use name if available in url even if only 1 …
Mar 27, 2013
af6bfe3
Changed "in_directory" variable reference to correct "in_subdirectory…
Mar 27, 2013
b7beea0
Added current version of qunit library files
Mar 27, 2013
b37cb86
Significant additions to README documentation
Mar 27, 2013
89034b8
Added on ability to include html template fragments on testing page.
Apr 4, 2013
355c2cd
Fixed formatting in template file
Apr 16, 2013
ecf5a9a
Fixed assumption about project structure. Now django_qunit can go in…
Jun 24, 2013
11599df
Updated to Django 1.5 url syntax
Jun 24, 2013
a95406f
Changed from single directory of qunit tests to allowing tests spread…
Jun 24, 2013
81a73dc
Fixed errors in template loading, url structure, etc.
Jun 24, 2013
88f7d3a
Updated README. Got rid of requirement for PROJECT_PATH. Replaced '…
Jun 24, 2013
fec18e6
Fixed example file, extended documentation
Jun 24, 2013
8049c38
Got rid of example folder, which isn't needed so much with the longer…
Jun 24, 2013
1dfa21a
Updated README and LICENSE to reflect that this is a significant chan…
Jun 24, 2013
dda3057
Updated MANIFEST.in
Jun 24, 2013
3c208ba
Moved snippet loader to base for easier packaging. Cleaned up and te…
Jun 24, 2013
90da564
README additions to reflect new installation option
Jun 24, 2013
80b78ab
Registered on pypi and added pip installation instructions
Jun 24, 2013
6d4ceed
README formatting fix
Jun 24, 2013
499657c
Changed to server qunit js and css files from static directory instea…
Aug 22, 2013
9feaee5
Updated manifest and setup files for new version. Moved files to the…
Aug 22, 2013
452d7a0
Added notes on changes to README. These should be integrated into th…
Aug 22, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pyc
/build
/dist
/django_qunit2.egg-info
43 changes: 21 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
Copyright (c) 2010, Cody Soyland
Copyright (c) 2013, Timothy Van Heest, Cody Soyland (original author)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of django-qunit nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CODY SOYLAND BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Includes QUnit, released under MIT license
------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include LICENSE
include README.md
include example/*
include example/qunit_tests/*
include django_qunit/media/qunit/*
include django_qunit/templates/qunit/*
recursive-include docs *
recursive-include django_qunit *
recursive-include django_qunit/static/css *
recursive-include django_qunit/static/js *
recursive-include django_qunit/templates/qunit *
104 changes: 95 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,104 @@ app and test Ajax routines.
[1]: http://docs.jquery.com/QUnit
[2]: http://www.djangoproject.com/

installation
Installation
============

1. Add 'django_qunit' to your settings.INSTALLED_APPS.
2. Add settings.QUNIT_TEST_DIRECTORY, containing the path to your javascript files.
3. Add a urlconf to include('django_qunit.urls').
4. Visit the URL you've included in your urlconf, and it should display QUnit test results.
1. Either:
* Install via [`pip install django_qunit2`](https://pypi.python.org/pypi/django-qunit2/20130624)
* Download the files / clone the repo and put the `django_qunit/django_qunit` folder where ever you put your projects apps
1. Add `django_qunit` (or `apps.django_qunit`, depending on which option you chose for the first step) to your `settings.INSTALLED_APPS`.
2. Add `'django_qunit.snippet_loader.Loader',` to `settings.TEMPLATE_LOADERS`.
3. Add `settings.QUNIT_TEST_PATH`, containing the path to the qunit test directory from within each app's static files directory, and your main project static directory. This is a file path, so make sure to use `os.path.join` to create the path.

For example, if `STATICFILES_DIRS` contains `"/path/to/my/project/static"` and `QUNIT_TEST_PATH` is `"qunit"`, place your test files inside a "qunit" folder in `os.path.join("/path/to/my/project/static", QUNIT_TEST_PATH)`.
Within each app, you should put the files in `appname/static_dir/QUNIT_TEST_PATH/appname/`. Adding in `appname` keeps tests namespaced and creates a natural tree structure for your tests.

4. Add a urlconf to `include('django_qunit.urls')`.

*See the example in the tarball for more information.*
If you would only like these urls available in debug mode, use something like the following in your base `urls.py` file.

license
if settings.DEBUG:
"""Test-only urls """
urlpatterns += patterns('',
(r'^qunit/', include('django_qunit.urls')),
)

5. Visit the URL you've included in your urlconf, and it should display QUnit test results.

Configuration
==============
* Qunit test directory layout

Extending upon the contents of the `examples` directory, we found something resembling the following works well, assuming `qunit` is your QUNIT_TEST_PATH.
Group tests into files then folders. Folders can be nested.

* qunit
* section_a
* test1.js
* test2.js
* stub_a.html
* suite.json
* section_b
* section_b1
* test1.js
* test1.js
* suite.json
* section_c
* test1.js
* test1.js
* suite.json

Within an app, first create a empty folder with the name of the app, then add more tests and test directories with that.

* qunit
* myapp
* test1.js
* test2.js
* stub1.html
* suite.json
* section_a
* section_b1
* test1.js
* test3.js
* suite.json
* section_b
* test4.js

* Test configuration files

Add a file named `suite.json` to any directory in `QUNIT_TEST_DIRECTORY` to change the displayed name of that testing directory
or change what external assets are loaded on that test page. For example, the following will load
the js files at the listed urls into the page `django-qunit` creates for the folder containing this configuration file.

You can also pass an array named `extra_media_urls`, and these urls will be concatenated with your project's value of `settings.MEDIA_URL`.

{
"extra_urls": [
"/static_assets/js/lib/jquery.js",
"/static_assets/js/lib/underscore.js",
"/static_assets/js/lib/jquery-ui.js"
]
}

Note that `suite.json` attributes are not inherited by lower level directories, so you need to define `suite.json` files for each
folder that needs additional assets loaded.

Additionally, you can include `.html` files in any testing directory. The contents of each of these files will be included on that
directory's testing page inside a `div` with an id determined by the name of the file. For example, for the example stuctur above,
`stub_a.html` would be included in a `div` with id `stub_a`. All html stubs are wrapped in a `div` with id `qunit-html-stubs`, and
this `div` is given the css property `display: none`.

Tips
=====

* You must have "django.contrib.staticfiles.finders.AppDirectoriesFinder" listed as one of your "STATICFILES_FINDERS"
* Your Django installation should be looking for static files under "appname/static". If you changed this, the static files for qunit may not be found.

License
=======
Copyright (c) 2012 Timothy Van Heest

Originally based off a fork of Cody Soyland's [django-qunit](https://github.com/codysoyland/django-qunit).

Copyright (c) 2010 Cody Soyland
Licensed new-style BSD, also containing QUnit, which is licensed MIT. See LICENSE file for more information.
Licensed MIT, also containing QUnit, which is licensed MIT. See LICENSE file for more information.
4 changes: 2 additions & 2 deletions django_qunit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from django.conf import settings

try:
settings.QUNIT_TEST_DIRECTORY
settings.QUNIT_TEST_PATH
except AttributeError:
raise ImproperlyConfigured('Missing required setting QUNIT_TEST_DIRECTORY.')
raise ImproperlyConfigured('Missing required setting QUNIT_TEST_PATH.')
Loading