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.6KB

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. * Write tests! Pull requests will be rejected if sufficient tests aren't
  8. provided. See the guidance below on the testing conventions that oscar uses
  9. * Make pull requests against Oscar's master branch unless instructed otherwise.
  10. * Please update the documentation when altering behaviour or introducing new features.
  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 well. 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 for categories and shipping
  68. countries.
  69. Writing docs
  70. ============
  71. There's a helper script for building the docs locally::
  72. cd docs
  73. ./test_docs.sh
  74. Conventions
  75. ===========
  76. General
  77. -------
  78. * PEP8 everywhere while remaining sensible
  79. URLs
  80. ----
  81. * List pages should use plurals, eg ``/products/``, ``/notifications/``
  82. * Detail pages should simply be a PK/slug on top of the list page, eg
  83. ``/products/the-bible/``, ``/notifications/1/``
  84. * Create pages should have 'create' as the final path segment, eg
  85. ``/dashboard/notifications/create/``
  86. * Update pages are sometimes the same as detail pages (ie when in the
  87. dashboard). In those cases, just use the detail convention, eg
  88. ``/dashboard/notifications/3/``. If there is a distinction between the detail
  89. page and the update page, use ``/dashboard/notifications/3/update/``.
  90. * Delete pages, eg ``/dashboard/notifications/3/delete/``
  91. View class names
  92. ----------------
  93. Classes should be named according to::
  94. '%s%sView' % (class_name, verb)
  95. For example, ``ProductUpdateView``, ``OfferCreateView`` and
  96. ``PromotionDeleteView``. This doesn't fit all situations but it's a good basis.