예제 #1
0
    def test_update_and_save(self):
        # first update
        assembly.Assembly().update_and_save(self.ctx, self.data[0]['id'],
                                            {'status': 'DELETING'})
        updated = assembly.Assembly().get_by_id(self.ctx, self.data[0]['id'])
        self.assertEqual('DELETING', getattr(updated, 'status'))

        # second update, 'DELETING' status is not updatable
        assembly.Assembly().update_and_save(self.ctx, self.data[0]['id'],
                                            {'status': 'DEPLOYMENT_COMPLETE'})
        updated = assembly.Assembly().get_by_id(self.ctx, self.data[0]['id'])
        self.assertEqual('DELETING', getattr(updated, 'status'))
예제 #2
0
 def test_update_and_save_raise_exp(self, mock_log, mock_sess):
     mock_sess.return_value.merge.side_effect = sqla_ex.StaleDataError
     self.assertRaises(sqla_ex.StaleDataError,
                       assembly.Assembly().update_and_save, self.ctx,
                       self.data[0]['id'], {'status': 'DELETING'})
     expected = [
         mock.call("Failed DB call update_and_save. "
                   "Retrying 2 more times."),
         mock.call("Failed DB call update_and_save. "
                   "Retrying 1 more times."),
         mock.call("Failed DB call update_and_save. "
                   "Retrying 0 more times.")
     ]
     self.assertEqual(expected, mock_log.warning.call_args_list)
예제 #3
0
 def test_check_data(self):
     ta = assembly.Assembly().get_by_id(self.ctx, self.data[0]['id'])
     for key, value in self.data[0].items():
         self.assertEqual(value, getattr(ta, key))