示例#1
0
 def test_id(self):
     '''
   test initializer with id
   '''
     #
     id = 3
     o = sasmol.SasSys(id)
     self.assertEqual(o.id(), id)
 def test_id_systype_hybrid(self):
     '''
   test add object for a hybrid type
   '''
     #
     o = sasmol.SasSys(0)
     o.add_object('hybrid')
     self.assertEqual(o._objectarray[0][0], 0)
     self.assertEqual(o._objectarray[0][1]._name, 'Hybrid_None')
 def test_id_systype_sol(self):
     '''
   test add object for a solid type
   '''
     #
     o = sasmol.SasSys(0)
     o.add_object('solid')
     self.assertEqual(o._objectarray[0][0], 0)
     self.assertEqual(o._objectarray[0][1]._name, 'Sol_None')
 def test_id_systype(self):
     '''
   test initializer with id and systype of atomic
   '''
     #
     id = 3
     systype = 'atomic'
     o = sasmol.SasSys(id, systype)
     self.assertEqual(o.id(), id)
     self.assertEqual(o.systype(), systype)
示例#5
0
 def test_id_wrong(self):
     '''
   test initializer with the wrong systype input
   '''
     #
     id = 3
     systype = 'whatisthis'
     o = sasmol.SasSys(id, systype)
     self.assertEqual(o.id(), id)
     with self.assertRaises(Exception):
         self.assertEqual(o.systype(), systype)
 def test_id_systype_atomic(self):
     '''
   test add object for an atomic type
   '''
     #
     o = sasmol.SasSys(0)
     o.add_object('atomic')
     self.assertEqual(o._objectarray[0][0], 0)
     self.assertEqual(o._objectarray[0][1].id(), 0)
     self.assertEqual(o._objectarray[0][1].totalmass(), 0.0)
     self.assertEqual(o._objectarray[0][1].natoms(), 0)
     self.assertEqual(o._objectarray[0][1].mass(), None)
     self.assertEqual(o._objectarray[0][1].coor(), None)
     self.assertEqual(o._objectarray[0][1].com(), None)
 def test_wrong(self):
     '''
   test add object for a wrong type
   '''
     #
     import sys, os
     o = sasmol.SasSys(0)
     stdoutFileName = __file__ + '.stdiout'
     sys.stdout = open(stdoutFileName, 'w')
     o.add_object('whatisthis')
     sys.stdout = sys.__stdout__
     info = open(stdoutFileName).readlines()
     expected_info = [
         '>>> error: need to specify addtype == atom, molecule, or assembly\n',
         '>>> no objects created\n'
     ]
     self.assertEqual(info, expected_info)
     os.remove(stdoutFileName)
 def test_id_systype_atomic_sol_hybrid(self):
     '''
   test add object for atomic+solid_hybrid type
   '''
     #
     o = sasmol.SasSys(0)
     o.add_object('atomic')
     o.add_object('solid')
     o.add_object('hybrid')
     self.assertEqual(o._objectarray[0][0], 0)
     self.assertEqual(o._objectarray[0][1].id(), 0)
     self.assertEqual(o._objectarray[0][1].totalmass(), 0.0)
     self.assertEqual(o._objectarray[0][1].natoms(), 0)
     self.assertEqual(o._objectarray[0][1].mass(), None)
     self.assertEqual(o._objectarray[0][1].coor(), None)
     self.assertEqual(o._objectarray[0][1].com(), None)
     self.assertEqual(o._objectarray[1][0], 1)
     self.assertEqual(o._objectarray[1][1]._name, 'Sol_None')
     self.assertEqual(o._objectarray[2][0], 2)
     self.assertEqual(o._objectarray[2][1]._name, 'Hybrid_None')