hacker.rst 1.68 KB
Newer Older
Jamesie Pic's avatar
Quality  
Jamesie Pic committed
1 2 3
Hacker guide
~~~~~~~~~~~~

4 5 6 7 8 9 10 11 12
See a `hacking demo on the Memopol project in some epic
slides
<https://slides.com/jamespic/cd-devops/fullscreen#/>`_.

Read about it in `Continuous Delivery and DevOps
quickstart
<https://www.packtpub.com/application-development/continuous-delivery-and-devops-%E2%80%93-quickstart-guide-second-edition)>`_,
and I bet you'll order a paperback edition for reference !

Jamesie Pic's avatar
Jamesie Pic committed
13 14 15 16 17 18
Testing
=======

Use the ``tox -l`` command to list tests::

    $ pip install tox
19
    $ cd memopol/
Jamesie Pic's avatar
Jamesie Pic committed
20 21 22 23 24 25 26 27 28
    $ tox -l

Use the ``tox -e`` command to execute a particular test suite::

    $ tox -e py27

And use the ``tox`` command without argument to execute all test suites,
exactly like in CI.

Jamesie Pic's avatar
Quality  
Jamesie Pic committed
29 30 31 32 33
Adding random recommendations
=============================

::

Jamesie Pic's avatar
Jamesie Pic committed
34
    $ memopol shell
Jamesie Pic's avatar
Quality  
Jamesie Pic committed
35 36 37 38 39 40
    In [1]: from representatives_votes.models import Proposal
    In [2]: from votes.models import Recommendation
    In [3]: import random

    In [4]: for p in Proposal.objects.all(): Recommendation.objects.create(proposal=p, recommendation='for', weight=random.randint(1,10))

Jamesie Pic's avatar
Jamesie Pic committed
41 42 43 44 45 46 47 48 49 50

Creating test fixtures
======================

The largest test fixtures are, the longer it takes to load them, the longer the
test run is.

To create test fixtures for representatives_positions, insert some Position
objects, and reduce the database with::

Jamesie Pic's avatar
Jamesie Pic committed
51 52 53
    memopol remove_representatives_without_position
    memopol remove_groups_without_mandate
    memopol remove_countries_without_group
Jamesie Pic's avatar
Jamesie Pic committed
54 55 56

For representatives_recommendations::

Jamesie Pic's avatar
Jamesie Pic committed
57 58 59 60 61
    memopol remove_proposals_without_recommendation
    memopol remove_dossiers_without_proposal
    memopol remove_representatives_without_vote
    memopol remove_groups_without_mandate
    memopol remove_countries_without_group