Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit d401ace

Browse files
author
Janneke Janssen
committed
Use restructured text rather than Markdown
1 parent 5bc7567 commit d401ace

File tree

5 files changed

+120
-91
lines changed

5 files changed

+120
-91
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include LICENSE
2-
include README.md
2+
include README.rst
33
include MANIFEST.in
44

55
recursive-include testhook *.py

README.md

Lines changed: 0 additions & 88 deletions
This file was deleted.

README.rst

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
django-testhook
2+
===============
3+
4+
A Django template tag to enable testhook attributes on HTML elements.
5+
6+
.. image:: https://travis-ci.org/jjanssen/django-testhook.svg?branch=master
7+
:target: http://travis-ci.org/jjanssen/django-testhook
8+
.. image:: https://img.shields.io/pypi/v/django-testhook.svg
9+
:target: https://pypi.python.org/pypi/django-testhook/
10+
.. image:: https://img.shields.io/pypi/dm/django-testhook.svg
11+
:target: https://pypi.python.org/pypi/django-testhook/
12+
.. image:: https://img.shields.io/badge/wheel-yes-green.svg
13+
:target: https://pypi.python.org/pypi/django-testhook/
14+
.. image:: https://img.shields.io/pypi/l/django-testhook.svg
15+
:target: https://pypi.python.org/pypi/django-testhook/
16+
.. image:: https://img.shields.io/pypi/pyversions/Django.svg
17+
:target: https://pypi.python.org/pypi/django-testhook/
18+
.. image:: https://coveralls.io/repos/jjanssen/django-testhook/badge.svg?branch=master
19+
:target: https://coveralls.io/github/jjanssen/django-testhook?branch=master
20+
21+
About django-testhook
22+
---------------------
23+
24+
The django-testhook provides a template tag to generate
25+
``data-testhook-id`` for HTML templates.
26+
27+
This can be useful for automated testing (for eg:
28+
`Webdriver.IO <http://www.webdriver.io>`__) to maintain a fixed entry
29+
point, rather than having a automated test that breaks by just renaming
30+
a CSS class or an element which can require you to re-evaluate an
31+
XPath-selector.
32+
33+
Requirements
34+
------------
35+
36+
Django 1.8.x or greater, Python 2.7 or greater.
37+
38+
Installation
39+
------------
40+
41+
Install django-testhook with pip:
42+
43+
::
44+
45+
$ pip install django-testhook
46+
47+
Configuration
48+
-------------
49+
50+
Configuring django-testhook
51+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
Add the following to your settings file:
54+
55+
.. code:: python
56+
57+
INSTALLED_APPS += (
58+
'testhook',
59+
)
60+
61+
Available settings
62+
~~~~~~~~~~~~~~~~~~
63+
64+
By default the rendering of testhook data attributes is enabled. If you
65+
are in the scenario you want to disable it for a certain environment
66+
just configure it to ``False``.
67+
68+
.. code:: python
69+
70+
TESTHOOK_ENABLED = False
71+
72+
Usage
73+
-----
74+
75+
Basic usage
76+
~~~~~~~~~~~
77+
78+
Within your HTML template you must load the testhook tag in order to use
79+
it. The testhook tag only requires a single argument in order to return
80+
a result.
81+
82+
.. code:: html
83+
84+
{% load testhook %}
85+
86+
<div class="my-elem" {% testhook "test-elem" %}>
87+
I want to test this
88+
</div>
89+
90+
This will output to the following:
91+
92+
.. code:: html
93+
94+
<div class="my-elem" data-testhook-id="test-elem">
95+
I want to test this
96+
</div>
97+
98+
Object Usage
99+
~~~~~~~~~~~~
100+
101+
For dynamic elements there is also the option to pass arguments. For eg:
102+
given I have a product in a shopping basket with a primary key and a
103+
slug I could use it like this:
104+
105+
.. code:: html
106+
107+
<div class="item" {% testhook "basket" product.id product.slug %}>
108+
{{ product.title }}
109+
</div>
110+
111+
It will output to:
112+
113+
.. code:: html
114+
115+
<div class="item" data-testhook-id="basket-1-product-slug">
116+
A product title
117+
</div>

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
universal = 1
44

55
[metadata]
6-
description-file = README.md
6+
description-file = README.rst

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
description='''A Django template tag to enable testhook
2121
attributes on HTML elements.''',
22-
long_description=open('README.md').read(),
22+
long_description=open('README.rst').read(),
2323

2424
author='Janneke Janssen',
2525
author_email='[email protected]',

0 commit comments

Comments
 (0)