gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] mailing list


From: Carlos Moro
Subject: Re: [Gnumed-devel] mailing list
Date: Mon, 31 May 2004 16:39:32 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Hi

Sebastian Hilbert wrote:

I would like to see another mailing list set up that contains cvs commit messages.

I agree. It's very useful to follow and review latest changes.

It's very hard for me to follow and adapt to constant api changes all over our CVS tree. That way I would hopefully be able to identify the file better/faster which causes my code to stop working every once in a while (besides my bugs that is). This might be a beginner problem but would enable me to contribute more efficiently.
Not at all a beginner matter. It's a real and important problem, that can lead to frustation in certain circustances. Eg., you try to advance an API and when you try to implement next method, some change broke previous methods... maybe in another classes... So go back again withouth knowing where's exactly the problem... The difficulty arises much harder if you are trying the code by running the application, findind the problem can result a weird task....

One useful solution (which i'm actually trying in gmClinicalRecord and value objects) (not suddenly for all tree, but for example as you are fixating/implementing some methods) is the availability of a flexible and robust enought testing code. Pyunit, which is included in python standard distribution) is a great tool for such situations. You can define your test suites to test the methods you're developing/fixing/interested. Just by running the test, you can know exactly what's broken, where/why and look at the pyunit log (not the entire application log). I'm using it daily and it works quite fine.

I've got gmClinicalRecordTest, which is progressively testing each gmClinicalRecord methods (which actually are under heavy development and changing a lot). It's really useful for personal work. Another discussion might be if we could find it useful to go by adding these test classes to the tree so we could, at a moment test current tree status, and know the exact state of our code in every moment... maybe a paralel test tree dir structure?

Best regards,
Carlos

Code example:
----------------------------------------------------
python unittest.py gmClinicalRecordTest.gmClinicalRecordTestSuite -> test cases included in suite python unittest.py gmClinicalRecordTest.gmClinicalRecordTestCase.testInstantiateExistingEMR -> test specific case

PD: If you fin it useful, i can prepare s small snip doc for wiki

--------------------------------------------------------------------------------------
"""
Unit tests for GnuMed gmClinicalRecord
"""
#============================================================
import unittest
from Gnumed.pycommon import gmPG, gmExceptions
from Gnumed.business import gmClinicalRecord, gmEMRStructItems, gmAllergy
class gmClinicalRecordTestCase(unittest.TestCase):
  #--------------------------------------------------------
  # Fixture initializer and finalizer methods
#-------------------------------------------------------- def setUp(self):
      _ = lambda x:x
      gmPG.set_default_client_encoding('latin1')
      # Let's instantiante Captain Kirk's EMR
      # Modify its PK to adapt to your backend to run the tests
      self.patient_id = 13
      self.emr = gmClinicalRecord.cClinicalRecord(aPKey = self.patient_id)
        def tearDown(self):
gmPG.ConnectionPool().StopListeners() #--------------------------------------------------------
  # health issues API
#-------------------------------------------------------- def testInstantiateExistingEMR(self): """Check that an existing patient clinical record can be instantiated"""
      self.assertEqual(self.emr.id_patient, self.patient_id)
        def testInstantiateNonExistingEMR(self):
"""Check that a non existing patient clinical record can't be instantiated""" self.assertRaises(gmExceptions.ConstructorError, gmClinicalRecord.cClinicalRecord, aPKey = -1 )

# Fancy way to build a suite
class gmClinicalRecordTestSuite(unittest.TestSuite):
  def __init__(self):
      unittest.TestSuite.__init__(self,map(gmClinicalRecordTestCase,
("testInstantiateExistingEMR", "testInstantiateNonExistingEMR", "testGetHealthIssues")))

# Make this test module runnable from the command prompt
if __name__ == "__main__":
  unittest.main()

--------------------------------------







reply via email to

[Prev in Thread] Current Thread [Next in Thread]