Changeset 12920 for main


Ignore:
Timestamp:
9 May 2015, 21:48:17 (10 years ago)
Author:
Henrik Bettermann
Message:

Untegrate doctests into sphinx docu.

Location:
main/waeup.kofa/trunk
Files:
3 added
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/docs/source/userdocs/testing.rst

    r12915 r12920  
    44**************************
    55
    6 Doc Tests
    7 =========
     6DocTests
     7========
    88
    99.. toctree::
     
    1616   testing/permissions
    1717   testing/userscontainer
     18   testing/certificate
     19   testing/batching
    1820   testing/batchprocessing
     21   testing/accesscode
     22
     23
     24Python Tests
     25============
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/accesscode.txt

    r7819 r12920  
    1 :mod:`waeup.kofa.accesscodes.accesscode` -- access codes (aka PINs)
    2 *******************************************************************
     1Access Codes (aka PINs)
     2***********************
    33
    44.. module:: waeup.kofa.accesscodes.accesscode
     
    99.. :NOlayer: waeup.kofa.testing.KofaUnitTestLayer
    1010
    11 About access-codes
     11About Access Codes
    1212==================
    1313
     
    3434
    3535
    36 AccessCode
    37 ==========
     36Access Code
     37===========
    3838
    3939.. class:: AccessCode(batch_serial, random_num[,invalidation_date=None[, student_id=None]])
    4040
    41    You normally shouldn't create standalone access-codes. Use
     41   You normally shouldn't create standalone access codes. Use
    4242   instances of :class:`AccessCodeBatch` instead as they generate them
    4343   (in masses) and care for them.
     
    4747   :class:`AccessCodeBatch`) to be kept.
    4848
    49    Access-codes can have three states: unused, used, and
    50    disabled. While still unused but enabled access-codes are reflected
     49   Access codes can have three states: unused, used, and
     50   disabled. While still unused but enabled access codes are reflected
    5151   by an empty ``invalidation_date`` (set to ``None``), an already
    5252   used (invalidated) code provides an invalidation date.
    5353
    54    In case of misuse or similar cases access-codes can also be
     54   In case of misuse or similar cases access codes can also be
    5555   completely disabled by setting the ``disabled`` attribute to
    5656   ``True``.
     
    133133
    134134
    135 AccessCodeBatch
    136 ===============
     135Access Code Batch
     136=================
    137137
    138138.. class:: AccessCodeBatch(creation_date, creator, batch_prefix, cost, entry_num, num)
    139139
    140    Create a batch of access-codes.
     140   Create a batch of access codes.
    141141
    142142   :param creation_date: python datetime
     
    152152   :class:`waeup.kofa.accesscodes.interfaces.IAccessCodeBatch`.
    153153
    154    When creating a batch, all entries (access-codes) are generated as
     154   When creating a batch, all entries (access codes) are generated as
    155155   well.
    156156
     
    170170   .. attribute:: entry_num
    171171
    172       Number of entries (access-codes) inside the batch.
     172      Number of entries (access codes) inside the batch.
    173173
    174174   .. attribute:: invalidated_num
     
    298298      Lookup is done via local BTrees and therefore pretty fast.
    299299
    300       Returns a list of access-codes found or empty list.
     300      Returns a list of access codes found or empty list.
    301301
    302302
     
    312312    True
    313313
    314 Creating a batch of three access-codes, with a cost of ``12.12`` per
     314Creating a batch of three access codes, with a cost of ``12.12`` per
    315315code, the batch prefix ``APP``, batch number ``10``, creator ID
    316316``Fred`` and some arbitrary creation date:
     
    321321    ...   datetime.datetime(2009, 12, 23), 'Fred','APP', 12.12, 3, num=10)
    322322
    323 Getting all access-codes from a batch:
     323Getting all access codes from a batch:
    324324
    325325    >>> ac_codes = batch.entries()
     
    472472#    []
    473473
    474 AccessCodeBatchContainer
    475 ========================
     474Access Code Batch Container
     475===========================
    476476
    477477.. class:: AccessCodeBatchContainer()
     
    540540        be a string containing the full student ID.
    541541
    542 Examples:
    543 ---------
     542Examples
     543--------
    544544
    545545Creating a batch container:
     
    586586
    587587
    588 Access code plugin
     588Access Code Plugin
    589589==================
    590590
     
    592592
    593593  A `waeup.kofa` plugin that updates existing Kofa university
    594   instances so that they provide support for access-codes.
     594  instances so that they provide support for access codes.
    595595
    596596  .. attribute:: grok.implements(IKofaPluggable)
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/browser.txt

    r11254 r12920  
    1 :mod:`waeup.kofa.accesscodes.browser` -- UI components for access-codes
    2 ***********************************************************************
     1UI Components for Access Codes
     2******************************
    33
    44.. module:: waeup.kofa.accesscodes.browser
     
    4545
    4646
    47 Access-code management screen
     47Access Code Management Screen
    4848=============================
    4949
     
    6666    ...
    6767
    68 Adding batches
     68Adding Batches
    6969==============
    7070
     
    336336
    337337Enabling and Disabling Found Access Codes
    338 -----------------------------------------
     338=========================================
    339339
    340340If a search is successfull, we can enable or disable the found access
     
    421421
    422422
    423 
    424423Archive files
    425424-------------
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/batchprocessing.txt

    r12868 r12920  
    1 Batch processing via browser
     1Batch Processing via Browser
    22****************************
    33
     
    5858
    5959
    60 Batch processing faculties
     60Batch Processing Faculties
    6161==========================
    6262
     
    166166
    167167
    168 Batch processing departments
     168Batch Processing Departments
    169169============================
    170170
     
    231231    ...File:...departments_zope.mgr.csv...
    232232
    233 Batch processing courses
     233Batch Processing Courses
    234234========================
    235235
     
    296296    ...File:...courses_zope.mgr.csv...
    297297
    298 Batch processing certificates
     298Batch Processing Certificates
    299299=============================
    300300
     
    362362    ...File:...certificates_zope.mgr.csv...
    363363
    364 Batch processing certificate courses
     364Batch Processing Certificate Courses
    365365====================================
    366366
     
    427427    ...File:...mycertcourses_zope.mgr.csv...
    428428
    429 Batch processing users
     429Batch Processing Users
    430430======================
    431431
     
    499499   ['waeup.PortalManager', 'waeup.AcademicsOfficer', 'waeup.ImportManager']
    500500
    501 Pending files
     501Pending Files
    502502=============
    503503
     
    587587
    588588
    589 Fixing the pending file
     589Fixing the Pending File
    590590-----------------------
    591591
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/browser.txt

    r12919 r12920  
    984984
    985985
    986 CertificateCourses
    987 ==================
     986Certificate Courses
     987===================
    988988
    989989Once we have a certificate, we can add also certificate courses. These
     
    10301030
    10311031
    1032 Adding certificatecourses
    1033 -------------------------
     1032Adding certificate courses
     1033--------------------------
    10341034
    10351035Certcourses are stored in :class:`ICertificate` instances
     
    10571057  ['--', 'COURSE1 - Course 1', 'COURSE2 - Course 2']
    10581058
    1059 We select the first course and create our certificatecourse:
     1059We select the first course and create our certificate course:
    10601060
    10611061  >>> ctrl.getControl('COURSE1').selected = True
     
    10631063  >>> browser.getControl('Add certificate course').click()
    10641064
    1065 Our certificatecourse will be linked on the parent certificate page:
     1065Our certificate course will be linked on the parent certificate page:
    10661066
    10671067  >>> browser.open(cert_url)
     
    10701070  'http://localhost/my...sity/faculties/TF/TD/certificates/CERT1/COURSE1_100'
    10711071
    1072 We can't add the same certificatecourse twice:
     1072We can't add the same certificate course twice:
    10731073
    10741074  >>> cert_url = dept_url + '/certificates/CERT1'
     
    10821082  True
    10831083
    1084 When we started to add a new certificatecourse, we can also cancel the
     1084When we started to add a new certificate course, we can also cancel the
    10851085process before submitting. This will bring us back to the certificate
    10861086page:
     
    10921092
    10931093
    1094 Modifying certificatecourses
    1095 ----------------------------
     1094Modifying certificate courses
     1095-----------------------------
    10961096
    10971097We can change the settings for a certcourse by clicking on the
     
    11371137  ...
    11381138
    1139 Searching certificatecourses
    1140 ----------------------------
     1139Searching certificate courses
     1140-----------------------------
    11411141
    11421142  >>> browser.open('http://localhost/myuniversity/faculties/search')
     
    11531153  True
    11541154
    1155 Deleting certificatecourses
    1156 ---------------------------
     1155Deleting certificate courses
     1156----------------------------
    11571157
    11581158We can delete certcourses by browsing the containing certificate manage page:
  • main/waeup.kofa/trunk/src/waeup/kofa/catalog.txt

    r7819 r12920  
    1 :mod:`waeup.kofa.catalog` -- Cataloging support Kofa
    2 ****************************************************
     1Cataloging Support
     2******************
    33
    44.. module:: waeup.kofa.catalog
     
    1010.. :layer: waeup.kofa.testing.KofaUnitTestLayer
    1111
    12 .. contents::
    13 
    14 Classes
    15 =======
    16 
    17 :class:`KofaQuery`
    18 ------------------
     12The KofaQuery Class
     13===================
    1914
    2015.. class:: KofaQuery()
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.txt

    r9589 r12920  
    1 Kofa Data Center
    2 ****************
     1Data Center
     2***********
    33
    44The Kofa data center cares for managing CSV files and importing then.
     
    4242
    4343Managing the storage path
    44 -------------------------
     44=========================
    4545
    4646We can set another storage path:
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt

    r12900 r12920  
    1 Kofa permissions and roles
    2 **************************
     1Permissions and Roles
     2*********************
    33
    44Permissions and roles used in a Kofa portal.
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certcourses.txt

    r9828 r12920  
    1 Certificate Courses
    2 *******************
    3 
    4 Courses are referred to by certificate courses.
    5 
    6 We can be sure, that when removing courses or referrers of them,
     1.. _removecertificatecourses:
     2
     3Persistence of Certificate Courses
     4==================================
     5
     6If a certificate course requires a certain course and this is course
     7is deleted, also the referring certificate course is deleted.
     8
     9We setup a data structure that reflects typical usage. It looks like
     10this::
     11
     12    Department-Instance
     13    |
     14    +---> courses
     15    |        |
     16    |        +--------------------> Course-Instance
     17    |                                        ^
     18    +---> certificates                       |
     19             |                               |
     20             +-----> Certificate-Instance    |
     21                        |                    |
     22                        +------> Certificate-Course
     23
     24The Certifcate Course here refers to a Course instance.
     25
     26In Python we build such a structure like this (from top to bottom):
     27
     28    >>> from zope.component import createObject
     29    >>> mydept = createObject('waeup.Department')
     30
     31In real world use this data will be stored in a ZODB. We setup our own
     32litte ZODB backend (which is easy!):
     33
     34    >>> from ZODB import FileStorage, DB
     35    >>> dbpath = 'tinyData.fs'
     36    >>> class TinyZODB(object):
     37    ...   def __init__(self, path=dbpath):
     38    ...     self.storage = FileStorage.FileStorage(path)
     39    ...     self.db = DB(self.storage)
     40    ...     self.connection = self.db.open()
     41    ...     self.dbroot = self.connection.root()
     42    ...   def close(self):
     43    ...     self.connection.close()
     44    ...     self.db.close()
     45    ...     self.storage.close()
     46
     47Now we can use this ZODB as backend database and store our data
     48structure:
     49
     50    >>> import transaction
     51    >>> db = TinyZODB()
     52    >>> dbroot = db.dbroot
     53    >>> dbroot['mydept'] = mydept
     54    >>> mycourse = createObject('waeup.Course')
     55    >>> mycourse.code = 'MYCOURSE'
     56    >>> mydept.courses.addCourse(mycourse)
     57    >>> mycert = createObject('waeup.Certificate')
     58    >>> mycert.code = 'MYCERT'
     59    >>> mydept.certificates.addCertificate(mycert)
     60    >>> mycert.addCertCourse(mycourse)
     61
     62    >>> transaction.commit()
     63
     64The data is now stored in the ZODB. We can close the DB, reopen it
     65later and the data will still be there:
     66
     67    >>> db.close()
     68    >>> newdb = TinyZODB()
     69    >>> newdbroot = newdb.dbroot
     70    >>> list(newdbroot)
     71    ['mydept']
     72
     73The certificate course we stored in the certificate is indeed a
     74referrer of the course, not a copy of it:
     75
     76    >>> course = newdbroot['mydept'].courses['MYCOURSE']
     77    >>> certcourse = newdbroot['mydept'].certificates['MYCERT']['MYCOURSE_100']
     78    >>> certcourse.course is course
     79    True
     80
     81So, we can be sure that modifications to the course are immediately
     82reflected in the certcourse.
     83
     84We can also be sure, that when removing courses or referrers of them,
    785other data will be handled in a way we expect. That is,
    886
     
    140218    >>> list(fac['DEPT2'].courses)
    141219    []
     220
     221
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.txt

    r12104 r12920  
    1 :mod:`waeup.kofa.university.certificate` -- Certificates for Kofa
    2 ******************************************************************
     1Certificates and Certificate Courses
     2************************************
    33
    44.. module:: waeup.kofa.university.certificate
     
    234234    <waeup.kofa.university.certificate.Certificate object at 0x...>
    235235
    236 CertificateCourses
    237 ------------------
     236Certificate Courses
     237-------------------
    238238
    239239:class:`CertificateCourse` instances comply with the
     
    258258    <waeup.kofa.university.certificate.CertificateCourse object at 0x...>
    259259
    260 .. _removecertificatecourses:
    261 
    262 Persistence of certificate courses
    263 ----------------------------------
    264 
    265 If a certificate course requires a certain course and this is course
    266 is deleted, also the referring certificate course is deleted.
    267 
    268 We setup a data structure that reflects typical usage. It looks like
    269 this::
    270 
    271     Department-Instance
    272     |
    273     +---> courses
    274     |        |
    275     |        +--------------------> Course-Instance
    276     |                                        ^
    277     +---> certificates                       |
    278              |                               |
    279              +-----> Certificate-Instance    |
    280                         |                    |
    281                         +------> Certificate-Course
    282 
    283 The certifcate-Course here refers to a Course-Instance.
    284 
    285 In Python we build such a structure like this (from top to bottom):
    286 
    287     >>> from zope.component import createObject
    288     >>> mydept = createObject('waeup.Department')
    289 
    290 In real world use this data will be stored in a ZODB. We setup our own
    291 litte ZODB backend (which is easy!):
    292 
    293     >>> from ZODB import FileStorage, DB
    294     >>> dbpath = 'tinyData.fs'
    295     >>> class TinyZODB(object):
    296     ...   def __init__(self, path=dbpath):
    297     ...     self.storage = FileStorage.FileStorage(path)
    298     ...     self.db = DB(self.storage)
    299     ...     self.connection = self.db.open()
    300     ...     self.dbroot = self.connection.root()
    301     ...   def close(self):
    302     ...     self.connection.close()
    303     ...     self.db.close()
    304     ...     self.storage.close()
    305 
    306 Now we can use this ZODB as backend database and store our data
    307 structure:
    308 
    309     >>> import transaction
    310     >>> db = TinyZODB()
    311     >>> dbroot = db.dbroot
    312     >>> dbroot['mydept'] = mydept
    313     >>> mycourse = createObject('waeup.Course')
    314     >>> mycourse.code = 'MYCOURSE'
    315     >>> mydept.courses.addCourse(mycourse)
    316     >>> mycert = createObject('waeup.Certificate')
    317     >>> mycert.code = 'MYCERT'
    318     >>> mydept.certificates.addCertificate(mycert)
    319     >>> mycert.addCertCourse(mycourse)
    320 
    321     >>> transaction.commit()
    322 
    323 The data is now stored in the ZODB. We can close the DB, reopen it
    324 later and the data will still be there:
    325 
    326     >>> db.close()
    327     >>> newdb = TinyZODB()
    328     >>> newdbroot = newdb.dbroot
    329     >>> list(newdbroot)
    330     ['mydept']
    331 
    332 The certificate course we stored in the certificate is indeed a
    333 referrer of the course, not a copy of it:
    334 
    335     >>> course = newdbroot['mydept'].courses['MYCOURSE']
    336     >>> certcourse = newdbroot['mydept'].certificates['MYCERT']['MYCOURSE_100']
    337     >>> certcourse.course is course
    338     True
    339 
    340 So, we can be sure that modifications to the course are immediately
    341 reflected in the certcourse.
    342 
  • main/waeup.kofa/trunk/src/waeup/kofa/userscontainer.txt

    r12079 r12920  
    1 User container for the Kofa
    2 ***************************
     1Users Container
     2***************
    33
    44.. :doctest:
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.txt

    r12868 r12920  
    1 :mod:`waeup.kofa.utils.batching` -- Batch processing
    2 ****************************************************
     1Batch Processing
     2****************
    33
    44Batch processing is much more than pure data import.
     
    7575
    7676
    77 Creating a batch processor
     77Creating a Batch Processor
    7878==========================
    7979
     
    361361
    362362
    363 
    364 
    365 Updating entries
     363Updating Entries
    366364----------------
    367365
     
    523521    >>> shutil.rmtree(os.path.dirname(result[2]))
    524522
    525 Removing entries
     523Removing Entries
    526524----------------
    527525
Note: See TracChangeset for help on using the changeset viewer.