File: development.rst

package info (click to toggle)
graphite-web 1.2.1~pre2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,976 kB
  • sloc: javascript: 86,824; python: 25,420; makefile: 124; sh: 91; ruby: 74; perl: 24
file content (93 lines) | stat: -rw-r--r-- 2,638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Working on Graphite-web
-----------------------

Graphite-web accepts contributions on `GitHub
<https://github.com/graphite-project/graphite-web>`_, in the form of issues or
pull requests. If you're comfortable with Python, here is how to get started.

First, keep in mind that Graphite-web supports Python versions **2.6 to 2.7**
and Django versions **1.4 and above**.

Setting up a development environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The recommended workflow is to use `virtualenv`_ / `virtualenvwrapper`_ to
isolate projects between each other. This document uses virtualenv as the
lowest common denominator.

.. _virtualenv: http://www.virtualenv.org/
.. _virtualenvwrapper: http://virtualenvwrapper.readthedocs.io/

Create a virtualenv at the root of your graphite-web repository::

    virtualenv env
    source env/bin/activate

Install the required dependencies::

    pip install -r requirements.txt

Create the default storage directories::

    mkdir -p storage/{ceres,whisper,log/webapp}

Then you should be able to run the graphite development server::

    cd webapp
    ./manage.py runserver

Running the tests
^^^^^^^^^^^^^^^^^

To run the tests for the Python and Django versions of your virtualenv::

    cd webapp
    ./manage.py test --settings=tests.settings

If you want to run the tests for all combinations of Python and Django
versions, you can use the `tox`_ tool.

.. _tox: http://tox.readthedocs.io/

::

    pip install tox
    tox

This will run the tests for all configurations declared in the ``tox.ini``
file at the root of the repository.

You can see all the configurations available by running::

    tox -l

You can run a single configuration with::

    tox -e <configuration>

Note that you need the corresponding python version on your system. Most
systems only provide one or two different python versions, it is up to you to
install other versions.

Writing tests
^^^^^^^^^^^^^

Pull requests for new features or bugfixes should come with tests to
demonstrate that your feature or fix actually works. Tests are located in the
``webapp/tests`` directory.

When writing a new test, look at the existing files to see if your test would
fit in one. Otherwise simply create a new file named ``test_<whatever>.py``
with the following content:

.. code-block:: python

    from django.test import TestCase

    class WhateverTest(TestCase):
        def test_something(self):
            self.assertEqual(1, 2 / 2)

You can read `Django's testing docs
<https://docs.djangoproject.com/en/stable/topics/testing/>`_ for more
information on ``django.test.TestCase`` and how tests work with Django.