Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

contributing.rst 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ============
  2. Contributing
  3. ============
  4. Some ground rules:
  5. * To avoid disappointment, new features should be discussed on the mailing list
  6. (django-oscar@googlegroups.com) before serious work starts.
  7. * Pull requests will be rejected if sufficient tests aren't provided.
  8. * Make pull requests against Oscar's master branch unless instructed otherwise.
  9. * Please update the documentation when altering behaviour or introducing new features.
  10. * Follow the conventions (see below).
  11. Installation
  12. ============
  13. After forking, run::
  14. git clone git@github.com:<username>/django-oscar.git
  15. cd django-oscar
  16. mkvirtualenv oscar # optional but recommended
  17. make install
  18. Running tests
  19. =============
  20. Oscar uses a nose_ testrunner which can be invoked using::
  21. ./runtests.py
  22. .. _nose: http://nose.readthedocs.org/en/latest/
  23. To run a subset of tests, you can use filesystem or module paths. These two
  24. commands will run the same set of tests::
  25. ./runtests.py tests/unit/order
  26. ./runtests.py tests.unit.order
  27. To run an individual test class use one of::
  28. ./runtests.py tests/unit/order:TestSuccessfulOrderCreation
  29. ./runtests.py tests.unit.order:TestSuccessfulOrderCreation
  30. (Note the ':'.)
  31. To run an individual test, use one of::
  32. ./runtests.py tests/unit/order:TestSuccessfulOrderCreation.test_creates_order_and_line_models
  33. ./runtests.py tests.unit.order:TestSuccessfulOrderCreation.test_creates_order_and_line_models
  34. Oscar's testrunner uses the progressive_ plugin when running all tests, but uses
  35. the spec_ plugin when running a subset. It is a good practice to name your test
  36. cases and methods so that the spec output reads correctly. For example::
  37. $ ./runtests.py tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount
  38. nosetests --verbosity 1 tests/unit/offer/benefit_tests.py:TestAbsoluteDiscount -s -x --with-spec
  39. Creating test database for alias 'default'...
  40. Absolute discount
  41. - consumes all lines for multi item basket cheaper than threshold
  42. - consumes all products for heterogeneous basket
  43. - consumes correct quantity for multi item basket more expensive than threshold
  44. - correctly discounts line
  45. - discount is applied to lines
  46. - gives correct discount for multi item basket cheaper than threshold
  47. - gives correct discount for multi item basket more expensive than threshold
  48. - gives correct discount for multi item basket with max affected items set
  49. - gives correct discount for single item basket cheaper than threshold
  50. - gives correct discount for single item basket equal to threshold
  51. - gives correct discount for single item basket more expensive than threshold
  52. - gives correct discounts when applied multiple times
  53. - gives correct discounts when applied multiple times with condition
  54. - gives no discount for a non discountable product
  55. - gives no discount for an empty basket
  56. ----------------------------------------------------------------------
  57. Ran 15 tests in 0.295s
  58. .. _progressive: http://pypi.python.org/pypi/nose-progressive/
  59. .. _spec: http://darcs.idyll.org/~t/projects/pinocchio/doc/#spec-generate-test-description-from-test-class-method-names
  60. Playing in the sandbox
  61. ======================
  62. Oscar ships with a 'sandbox' site which can be run locally to play around with
  63. Oscar using a browser. Set it up by::
  64. make sandbox
  65. cd sites/sandbox
  66. ./manage.py runserver
  67. This will create the database and load some fixtures.
  68. Writing docs
  69. ============
  70. There's a helper script for building the docs locally::
  71. cd docs
  72. ./test_docs.sh
  73. Conventions
  74. ===========
  75. General
  76. -------
  77. * PEP8 everywhere while remaining sensible
  78. URLs
  79. ----
  80. * List pages should use plurals, eg ``/products/``, ``/notifications/``
  81. * Detail pages should simply be a PK/slug on top of the list page, eg
  82. ``/products/the-bible/``, ``/notifications/1/``
  83. * Create pages should have 'create' as the final path segment, eg
  84. ``/dashboard/notifications/create/``
  85. * Update pages are sometimes the same as detail pages (ie when in the
  86. dashboard). In those cases, just use the detail convention, eg
  87. ``/dashboard/notifications/3/``. If there is a distinction between the detail
  88. page and the update page, use ``/dashboard/notifications/3/update/``.
  89. * Delete pages, eg /dashboard/notifications/3/delete/
  90. View class names
  91. ----------------
  92. Classes should be named according to::
  93. '%s%sView' % (class_name, verb)
  94. For example, ``ProductUpdateView``, ``OfferCreateView`` and
  95. ``PromotionDeleteView``. This doesn't fit all situations but it's a good basis.