Пример #1
0
	def test_isChanged(self):
		biz = self.biz
		self.assertEqual(biz.isChanged(), False)
		biz.Record.cField = "The Magnificent Seven"
		self.assertEqual(biz.isChanged(), True)
		biz.cancel()
		self.assertEqual(biz.isChanged(), False)

		# isChanged()	should be False for new records that haven't had any field
		# value changes.
		biz.new()
		self.assertEqual(biz.isChanged(), False)
		biz.Record.cField = "Hitsville U.K."
		self.assertEqual(biz.isChanged(), True)
Пример #2
0
    def testMementos(self):
        biz = self.biz
        cur = biz._CurrentCursor

        priorVal = biz.Record.cField

        # Make a change that is the same as the prior value:
        biz.Record.cField = priorVal
        self.assertEqual(priorVal, biz.Record.cField)

        # Make a change that is different:
        biz.Record.cField = "New test value"
        self.assertEqual(cur._mementos, {biz.Record.pk: {"cField": priorVal}})
        self.assertEqual(biz.isChanged(), True)

        # Change it back:
        biz.Record.cField = priorVal
        self.assertEqual(cur._mementos, {})
        self.assertEqual(biz.isChanged(), False)

        # Make a change that is different and cancel:
        biz.Record.cField = "New test value"
        biz.cancel()
        self.assertEqual(cur._mementos, {})
        self.assertEqual(biz.isChanged(), False)

        # Add a record:
        biz.new()

        self.assertEqual(biz.RowCount, 4)
        self.assertEqual(biz.RowNumber, 3)
        self.assertEqual(cur._newRecords, {-1: None})
        self.assertEqual(biz.isChanged(),
                         False)  ## (because no field changed in new record)
        self.assertEqual(cur.Record.pk, -1)
        self.assertEqual(biz.Record.cField, "")
        self.assertEqual(biz.Record.iField, 0)
        self.assertEqual(biz.Record.nField, 0)
        biz.save()
        self.assertEqual(
            biz.RowCount,
            4)  ## still have 4 rows, even though the last one wasn't saved
        biz.requery()
        # We only have 3 rows, because one of the prior 4 rows was new with no changed fields:
        self.assertEqual(biz.RowCount, 3)
        # ...and RowNumber went to 0, because the previous row number (3) doesn't exist anymore:
        self.assertEqual(biz.RowNumber, 0)
        self.assertEqual(cur._newRecords, {})
        self.assertEqual(biz.isChanged(), False)
        self.assertEqual(biz.Record.pk, 1)
Пример #3
0
    def test_isChanged(self):
        biz = self.biz
        self.assertEqual(biz.isChanged(), False)
        biz.Record.cField = "The Magnificent Seven"
        self.assertEqual(biz.isChanged(), True)
        biz.cancel()
        self.assertEqual(biz.isChanged(), False)

        # isChanged()	should be False for new records that haven't had any field
        # value changes.
        biz.new()
        self.assertEqual(biz.isChanged(), False)
        biz.Record.cField = "Hitsville U.K."
        self.assertEqual(biz.isChanged(), True)
Пример #4
0
	def testMementoSaveNewPotentialProblem(self):
		"""This attempts to reproduce problems being reported on
		dabo-users (see thread http://leafe.com/archives/showFullThd/374683)
		"""
		biz = self.biz
		self.assertEqual(biz.isChanged(), False)
		self.assertEqual(biz.isAnyChanged(), False)
		biz.new()
		self.assertEqual(biz.isChanged(), False)
		self.assertEqual(biz.isAnyChanged(), False)
		biz.Record.cField = 'ppp'
		self.assertEqual(biz.isChanged(), True)
		self.assertEqual(biz.isAnyChanged(), True)
		biz.save()
		self.assertEqual(biz.isChanged(), False)
		self.assertEqual(biz.isAnyChanged(), False)
Пример #5
0
    def testMementoSaveNewPotentialProblem(self):
        """This attempts to reproduce problems being reported on
		dabo-users (see thread http://leafe.com/archives/showFullThd/374683)
		"""
        biz = self.biz
        self.assertEqual(biz.isChanged(), False)
        self.assertEqual(biz.isAnyChanged(), False)
        biz.new()
        self.assertEqual(biz.isChanged(), False)
        self.assertEqual(biz.isAnyChanged(), False)
        biz.Record.cField = 'ppp'
        self.assertEqual(biz.isChanged(), True)
        self.assertEqual(biz.isAnyChanged(), True)
        biz.save()
        self.assertEqual(biz.isChanged(), False)
        self.assertEqual(biz.isAnyChanged(), False)
Пример #6
0
	def testMementos(self):
		biz = self.biz
		cur = biz._CurrentCursor

		priorVal = biz.Record.cField

		# Make a change that is the same as the prior value:
		biz.Record.cField = priorVal
		self.assertEqual(priorVal, biz.Record.cField)

		# Make a change that is different:
		biz.Record.cField = "New test value"
		self.assertEqual(cur._mementos, {biz.Record.pk: {"cField": priorVal}})
		self.assertEqual(biz.isChanged(), True)

		# Change it back:
		biz.Record.cField = priorVal
		self.assertEqual(cur._mementos, {})
		self.assertEqual(biz.isChanged(), False)

		# Make a change that is different and cancel:
		biz.Record.cField = "New test value"
		biz.cancel()
		self.assertEqual(cur._mementos, {})
		self.assertEqual(biz.isChanged(), False)

		# Add a record:
		biz.new()

		self.assertEqual(biz.RowCount, 4)
		self.assertEqual(biz.RowNumber, 3)
		self.assertEqual(cur._newRecords, {-1: None})
		self.assertEqual(biz.isChanged(), False)  ## (because no field changed in new record)
		self.assertEqual(cur.Record.pk, -1)
		self.assertEqual(biz.Record.cField, "")
		self.assertEqual(biz.Record.iField, 0)
		self.assertEqual(biz.Record.nField, 0)
		biz.save()
		self.assertEqual(biz.RowCount, 4)  ## still have 4 rows, even though the last one wasn't saved
		biz.requery()
		# We only have 3 rows, because one of the prior 4 rows was new with no changed fields:
		self.assertEqual(biz.RowCount, 3)
		# ...and RowNumber went to 0, because the previous row number (3) doesn't exist anymore:
		self.assertEqual(biz.RowNumber, 0)
		self.assertEqual(cur._newRecords, {})
		self.assertEqual(biz.isChanged(), False)
		self.assertEqual(biz.Record.pk, 1)
Пример #7
0
	def test_DefaultValues(self):
		biz = self.biz
		biz.DefaultValues["iField"] = 2342
		biz.new()
		self.assertEqual(biz.Record.iField, 2342)
		self.assertEqual(biz.isChanged(), False)
Пример #8
0
 def test_DefaultValues(self):
     biz = self.biz
     biz.DefaultValues["iField"] = 2342
     biz.new()
     self.assertEqual(biz.Record.iField, 2342)
     self.assertEqual(biz.isChanged(), False)