def test_update(self):
        self.dbu.create_some_test_well_royalty_masters()

        # change all types of attributes, read another record and then read the record again to make sure
        # the changes were made.
        well = self.db.select('WellRoyaltyMaster', ID=2)
        well[0].WellEvent = 'Changed'
        well[0].LeaseID = 100
        well[0].CommencementDate = '2016-02-01 00:00:00'
        well[0].WellType = None
        self.db.update(well[0])
        well = self.db.select('WellRoyaltyMaster', ID=1)
        self.assertEqual(well[0].ID, 1)
        self.assertEqual(well[0].WellEvent, 'SKWI111062705025W300')
        well = self.db.select('WellRoyaltyMaster', ID=2)
        self.assertEqual(well[0].ID, 2)
        self.assertEqual(well[0].WellEvent, 'Changed')
        self.assertEqual(well[0].CommencementDate, datetime(2016, 2, 1, 0, 0))
        self.assertEqual(well[0].WellType, None)

        ds = DataStructure()
        self.assertRaises(AttributeError, self.db.update, ds)
        
        ds._table_name = 'WellRoyaltyMaster'
        self.assertRaises(AttributeError, self.db.update, ds)
        ds.ID = 100
        self.assertRaises(AppError, self.db.update, ds)
    def test_update(self):
        self.dbu.create_some_test_well_royalty_masters()

        # change all types of attributes, read another record and then read the record again to make sure
        # the changes were made.
        well = self.db.select("WellRoyaltyMaster", ID=2)
        well[0].WellEvent = "Changed"
        well[0].LeaseID = 100
        well[0].CommencementDate = "2016-02-01 00:00:00"
        well[0].WellType = None
        self.db.update(well[0])
        well = self.db.select("WellRoyaltyMaster", ID=1)
        self.assertEqual(well[0].ID, 1)
        self.assertEqual(well[0].WellEvent, "SKWI111062705025W300")
        well = self.db.select("WellRoyaltyMaster", ID=2)
        self.assertEqual(well[0].ID, 2)
        self.assertEqual(well[0].WellEvent, "Changed")
        self.assertEqual(well[0].CommencementDate, datetime(2016, 2, 1, 0, 0))
        self.assertEqual(well[0].WellType, None)

        ds = DataStructure()
        self.assertRaises(AttributeError, self.db.update, ds)

        ds._table_name = "WellRoyaltyMaster"
        self.assertRaises(AttributeError, self.db.update, ds)
        ds.ID = 100
        self.assertRaises(AppError, self.db.update, ds)
Пример #3
0
 def get_data_structure(self, table_name):
     """ This method must be called to create a valid database data structure. """
     ds = DataStructure()
     ds._table_name = table_name
     return ds
 def get_data_structure(self, table_name):
     """ This method must be called to create a valid database data structure. """
     ds = DataStructure()
     ds._table_name = table_name
     return ds