mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix updating attributes inside f-strings when columns are renamed
Summary: Upgrades asttokens and uses the newly released support for astroid trees in `asttokens.ASTText` which is needed to deal with f-strings (as opposed to `asttokens.ASTTokens`). Test Plan: Added a Python unit test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D4027
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
import testutil
|
||||
import test_engine
|
||||
@@ -78,6 +81,20 @@ class TestRenames(test_engine.EngineTestCase):
|
||||
}]
|
||||
]})
|
||||
|
||||
@unittest.skipUnless(six.PY3, "Python 3 only")
|
||||
def test_rename_inside_fstring(self):
|
||||
self.load_sample(self.sample)
|
||||
self.add_column("People", "CityUpper", formula="f'{$city.upper()}'")
|
||||
out_actions = self.apply_user_action(["RenameColumn", "People", "city", "ciudad"])
|
||||
self.assertPartialOutActions(out_actions, { "stored": [
|
||||
["RenameColumn", "People", "city", "ciudad"],
|
||||
["ModifyColumn", "People", "CityUpper", {"formula": "f'{$ciudad.upper()}'"}],
|
||||
["BulkUpdateRecord", "_grist_Tables_column", [24, 25], {
|
||||
"colId": ["ciudad", "CityUpper"],
|
||||
"formula": ["$addr.city", "f'{$ciudad.upper()}'"]
|
||||
}]
|
||||
]})
|
||||
|
||||
def test_rename_reference_attribute(self):
|
||||
# Slightly harder: renaming `$ref.COLUMN`
|
||||
self.load_sample(self.sample)
|
||||
|
||||
Reference in New Issue
Block a user