Esempio n. 1
0
 def testFromInstance(self):
     formdata = FormData.from_xforminstance(self.instance)
     self.assertEqual(date(2010,07,22), formdata.timeStart.date())
     self.assertEqual(date(2010,07,23), formdata.timeEnd.date())
     self.assertEqual("THIS_IS_THE_INSTANCEID", formdata.instanceID)
     self.assertEqual("THIS_IS_THE_DEVICEID", formdata.deviceID)
     self.assertEqual("THIS_IS_THE_USERID", formdata.userID)
Esempio n. 2
0
 def testCreateOrUpdate(self):
     self.assertEqual(0, FormData.objects.count())
     
     FormData.create_or_update_from_xforminstance(self.instance)
     self.assertEqual(1, FormData.objects.count())
     self.assertTrue(FormData.objects.all()[0].matches_exact(self.instance))
     
     FormData.create_or_update_from_xforminstance(self.instance)
     self.assertEqual(1, FormData.objects.count())
     self.assertTrue(FormData.objects.all()[0].matches_exact(self.instance))
     
     self.instance["form"]["meta"]["deviceID"] = "UPDATED_DEVICEID"
     FormData.create_or_update_from_xforminstance(self.instance)
     self.assertEqual(1, FormData.objects.count())
     self.assertTrue(FormData.objects.all()[0].matches_exact(self.instance))
     
     self.instance["form"]["meta"]["instanceID"] = "UPDATED_INSTANCEID"
     self.instance._id = "UPDATED_INSTANCEID"
     FormData.create_or_update_from_xforminstance(self.instance)
     self.assertEqual(2, FormData.objects.count())
     self.assertTrue(FormData.objects.get(instanceID="UPDATED_INSTANCEID").matches_exact(self.instance))
Esempio n. 3
0
 def testUpdate(self):
     formdata = FormData.from_xforminstance(self.instance)
     self.instance["form"]["meta"]["deviceID"] = "UPDATED_DEVICEID"
     formdata.update(self.instance)
     self.assertEqual("UPDATED_DEVICEID", formdata.deviceID)
     self.assertTrue(formdata.matches_exact(self.instance))
Esempio n. 4
0
 def testMatches(self):
     formdata = FormData.from_xforminstance(self.instance)
     self.assertTrue(formdata.matches_exact(self.instance))
     
     formdata.deviceID = "UPDATED_DEVICEID"
     self.assertFalse(formdata.matches_exact(self.instance))