def case_update_record(self, refresh_db_before): """ Create test record in ServerStatus table and then update it.""" original_status = "StatusOrig" update_status = "StatusUpdate" original_stat_obj = ServerStatusOp.add(original_status) updated_stat_local = ServerStatusOp.update(original_stat_obj, update_status) self.assertEqual(updated_stat_local.name, update_status) updated_stat_get = ServerStatusOp.get(name=update_status) self.assertTrue(len(updated_stat_get) is 1) self.assertEqual(updated_stat_get[0].name, update_status) self.assertEqual(updated_stat_get[0].id, original_stat_obj.id)
def test_update(self, mock_servstatus, mock_val_name, mock_db): """ Assumptions: - update method run """ new_name = "TestName" ip_obj = mock_servstatus() updated_ip = ServerStatusOp.update(ip_obj, new_name) self.assertTrue(mock_val_name.called) db_exp_calls = [ mock.call.session.add(updated_ip), mock.call.session.commit() ] mock_db.assert_has_calls(db_exp_calls)