Esempio n. 1
0
    def testaddatomicchange(self):
        """
        Here we test the add_atomic_change method.  We attempt to add a change with an index, without and index,
        with a valid change type and with an invalid change type. We also set an ndx and try to set the ndx via
        this method to make sure that the ndx is not overridden.
        """
        change = Change()

        # ---------- Test invalid change type (non-dictionary)
        self.assertRaises(ValueError, change.add_atomic_change, "CHANGE")

        # ---------- Test valid change type with ndx
        valid_change = {"parameters/Run_Number": 5}
        change.add_atomic_change(valid_change, ndx=5)
        self.assertEqual(change.change_list[0], valid_change, msg="Failed to set atomic change")

        # ---------- Test valid change with ndx after ndx already set
        change2 = Change()
        change2.ndx = 1
        change2.add_atomic_change(valid_change, ndx=5)
        self.assertEqual(change2.ndx, 1, msg="Set index after initial set")

        self.assertEqual(change2.change_list[0], valid_change, msg="Failed to set atomic change")