
#######################################################################
#  This file is part of GNOWSYS: Gnowledge Networking and
#  Organizing System.
#
#  GNOWSYS is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as
#  published by the Free Software Foundation; either version 3 of
#  the License, or (at your option) any later version.
#
#  GNOWSYS is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public
#  License along with GNOWSYS (COPYING); if not, write to the
#  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
#  Boston, MA  02110-1301  USA59 Temple Place, Suite 330,
#
######################################################################

__docformat__ = 'plaintext'
__contributor__= """   Jay Mehta (jay87.mehta@gmail.com)  """


The test script file when executed, accepts dbname, username,
password and host to create a mock test database followed by the
following checks:

     1. Metatype: creates a metatype with attributes 'title' and
        'description' attached to it.  When a metatype is added,
        Metatype.py should return the new ssid of the created
        Metatype. The same should be checked for the success.

     2. Objecttype: When an objecttype is added, objecttype.py should
        return new ssid of the created Objecttype. The same should be
        checked for the success.

        1. create an objecttype (OT1) as an instance of Metatype
           created at step 1.  A snapshot of Metatype should not be
           created, but rendered_nbh and nbh of the Metatype should
           be updated.

   	2. create an objecttype again with the same nid. Objecttype.py
           should return status_msg =='nid exists. can't create again
           with the same nid.', for the success of the test.
        
   	3. create an objecttype (subtypeof-OT1) which will be
           subtypeof objecttype ('OT1') created at 2.1 and with
           attributes 'title' and 'description' attached to it.  New
           snapshot of 'OT1' should not be created, but rendered_nbh, nbh
	   should be updated. 

	4. create an objectype ('subtypeof-OT12') which will be
           subtypeof OT1, and OT2.  New snapshot of 'OT1' and ' OT2'
           should not be created, but rendered_nbh, nbh of OT1 and OT2 
           should be updated.

     3. Relationtype: When a Relationtype is added, Relationtype.py
        should return a new ssid of the created Relationtype. The same
        should be checked for the success.

	3.1. create a relationtype 'Depends-ON' between OT2 and OT1
             where OT2 depends-on OT1.  New snapshot of 'OT1' and
             'OT2' should not be created, but rendered_nbh,nbh should
             get updated.  The relationtype's renderednbh, nbh should
             have entry of OT1 and OT2.

	3.2. create a relationtype 'Depends-ON' between
             'subtypeof-OT1','subtypeof-OT12' and 'OT1' where
             'subtypeof-OT1','subtypeof-OT12' depends-on 'OT1'.  New
             snapshot of 'subtypeof-OT1','subtypeof-OT12' and 'OT1'
             should not be created, but rendered_nbh, nbh should get
             updated.  New relationtype should not get created but
             relationtype's renderednbh, nbh should be updated to have
             entry of 'subtypeof-OT1','subtypeof-OT12' and 'OT1'

     4. Attributetype: When an Attributetype is added,
        Attributetype.py should return new ssid of the created
        Attributetype. The same should be checked for the success.
        Add an AT to OT1 and OT2. New snapshot of 'OT1' and ' OT2'
        should not be created, but rendered_nbh, nbh of 'OT1' and
        'OT2' should get updated.  The Attributetype's renderednbh,
        nbh should have entry of OT1 and OT2.

     5. Object: When a Object is added, Object.py returns the
        new ssid of the Object created . The same should be checked for the
        success. 
	
	1. create an object 'O1', instanceof 'OT1'.  New snapshot of
        'OT1' should not be created, but rendered_nbh,nbh of 'OT1'
        should get updated.

	2. create an object 'O12', instanceof 'OT1' and 'OT2'.  New
        snapshot of 'OT1' and ' OT2' should not get created, but
        rendered_nbh,nbh of 'OT1' and 'OT2' should get updated.

	3. create an object 'O1', instanceof ' OT1 and sub_OT1 ' with
        attributes 'title' and 'description' attach to it.  New
        snapshot of 'OT1' and 'sub-OT1' should not get created, but
        their rendered_nbh,nbh should get updated.

     6. Attribute: When a Attribute is added, Attribute.py returns new
        ssid of the subject to which it is attached. The same should
        be checked for the success.  Add attribute created at step 4
        to ' OT1 ' .

        whenever an attribute is added/updated to any subject, md5 of
        "subjectinid_attributetypeinid_attributevalue" should be taken
        and checked in md5sum table. If it exists corresponding
        attribute ssid is fetched else new attribute ssid should be
        created and entry should be made in md5sum table.
   
        whenever password is attached to the any subject its md5
        should be calculated and attached to the subject.

     7. Relation: when relation between 2 subject is created , entry
        for each subject should be made in rendered_nbh of another
        subject. Moreover relation should be created between inid of
        the subjects. If same relation is again created between new
        snaphots of the subjects then relations should not be created
        again but new snapshot of both subject are created and entry
        of subject should be made in rendered_nbh of another subject.
   
        1.create relation 'Depends-ON' between ' sub_OT1, sub_OT12,
        OT2 ' and ' OT1 '. [Relation should be created.].

	2.create relation 'Depends-ON' between ' O12 ' and ' O1
        '. [Relation should be created.]

	3.create relation 'Depends-ON' between ' O1_subO1 ' and ' O1
        '. [Relation should be created.]

	4.create relation 'Depends-ON' between ' O12 ,O1_subO1 ' and '
        O1 '. [Relation should be created.]

     8. Relation with no versioning of subjects involved in it: create
        relation 'Depends-ON' between 'O12, O1_subO1' and 'O1'. No new
        snapshot of 'O12, O1_subO1' and 'O1' are created. However
        their rendered_nbh and nbh gets updated.[Relation should be
        created.]

     9. Functions:When a Function is added, Functions.py returns new
        ssid of the created Objecttype. The same should be checked for
        the success.

        1. create a Function (F1) instanceof Metatype created at step
           1 with attributes 'title' and 'description' attach to it.

        2. Redefine relationtype 'Depends-ON' between ' F1' and 'F1 '.  

	3. create a function (sub-F1) instanceof Metatype (step 1) and
           subtypeof F1(step 9.1) and relation 'Depends-ON' with
           'F1'. It should generate error while creating relation
           Depends-ON.

   	4. create a function (sub-F2) instanceof Metatype (step 1) and
	   subtypeof F1(step 9.1) and relation 'Depends-ON' with 'F1' with
	   attributes 'title' and 'description' attach to it. It should create
	   and return new ssid of function created.

        5. create a function (sub-F1) instanceof Metatype (step 1) and
	   subtypeof F1(step 9.1) and relation 'Depends-ON' with 'sub-F2'(step
	   9.4) with attributes 'title' and 'description' attach to it. It should
	   create and return new ssid of function created.

     10. ProcessType: When a ProcessType is added, ProcessType.py
         returns new ssid of the created ProcessType. The same should
         be checked for the success.  Create a process type instanceof
         metatype (created at step 1) with attributes 'title' and
         'description' attach to it.

     11. Process: When a Process is added, Process.py returns new ssid
         of the created Process. The same should be checked for the
         success.  Create a process instanceof ProcessType( step 10)
         with attributes 'title' and 'description' attach to it.
	
     12. Usertype: When a Usertype is added, Usertype.py returns new
         ssid of the created Usertype. The same should be checked for
         the success.
         1. create a usertype 'gnowsys_tester_forum' with attributes
            'title' and 'description' attach to it.

         2. create a usertype 'gnowsys_document_forum', subtypeof
            default usertype 'GnowsysUser', with attributes 'title' and
           'description' attach to it .

         3. Following step 8 technique, create a usertype
            'gnowsys_tester_forum' (step 10.1) in relation subtypeof
            withdefault usertype 'GnowsysUser'.[should be created]
         4. create a relationtype 'grouped' between 2 usertype
            'gnowsys_tester_forum' and 'gnowsys_document_forum'.
         5. Since username,email,password are default attributes
            attached to only default usertype 'GnowsysUser', we attach
            all these 3 to 'gnowsys_tester_forum' and
            'gnowsys_document_forum'.
   
     13. User: When a User is added, User.py returns new ssid of the
         created User. The same should be checked for the success.
         1. create a user ('tester-1') instanceof 'GnowsysUser' and
            'gnowsys_tester_forum' with attributes
            'username'='g-tester1',
            'password'='g-tester1','email'='gtester1@gmail.com' attach
            to it. The user should be created with its ssid returned
            indicating successful creation of user.

         2. create a user ('tester-2') instanceof
            'gnowsys_document_forum' with attributes
            'username'='g-documenter1',
            'password'='g-documenter1','email'='gdocumenter1@gmail.com'
            attach to it and related 'grouped' to user ' tester-1 '
            (step 11.1) .

     14. Delete: when a attribute or relation or infact a node is
         deleted, a new snapshot is created of that node with
         attributes,relation detached from it that were given in
         input.

	 1. when a relation does not exists and an attempt is made to
            delete it, an error messge is checked for the sucess of
            the test.
	    Delete relation 'Depends-ON' from subject 'OT1'
            related to 'OT2'  and check for the error message.

	 2. Delete relation 'Depends-ON' from subject 'OT1' where
            'OT1' is related to 'OT2' and check for the new ssid of
            'OT1' returned for the success of test.
	   
     15. Update: when new attributes are attached or some of them are
         update along with creating relation of that subject with some
         other, new snapshot of that subject is created on sucessful
         attributes and relation addition/updation.
	 1. Create new object 'O3' instanceof 'OT2' with attributes
            'title' and 'description' attach to it.  Using update
            methods, update 'title' keeping 'description' same and
            create relation 'Depends-ON' and 'partof' with 'O1'.
