(core) Attempt to fix test_formula_prompt test broken by a merge

Test Plan: Tests should pass

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3797
This commit is contained in:
Dmitry S 2023-02-11 14:57:56 -05:00
parent ddde364e5d
commit d70a7209f7

View File

@ -8,18 +8,26 @@ from formula_prompt import (
values_type, column_type, referenced_tables, get_formula_prompt, values_type, column_type, referenced_tables, get_formula_prompt,
) )
from objtypes import RaisedException from objtypes import RaisedException
from records import Record, RecordSet from records import Record as BaseRecord, RecordSet as BaseRecordSet
class FakeTable(object): class FakeTable(object):
def __init__(self): def __init__(self):
pass class Record(BaseRecord):
_table = self
class RecordSet(BaseRecordSet):
_table = self
self.Record = Record
self.RecordSet = RecordSet
table_id = "Table1" table_id = "Table1"
_identity_relation = None _identity_relation = None
fake_table = FakeTable()
@unittest.skipUnless(six.PY3, "Python 3 only") @unittest.skipUnless(six.PY3, "Python 3 only")
class TestFormulaPrompt(test_engine.EngineTestCase): class TestFormulaPrompt(test_engine.EngineTestCase):
def test_values_type(self): def test_values_type(self):
@ -38,22 +46,22 @@ class TestFormulaPrompt(test_engine.EngineTestCase):
self.assertEqual(values_type([1, 2, "3", None]), "Any") self.assertEqual(values_type([1, 2, "3", None]), "Any")
self.assertEqual(values_type([ self.assertEqual(values_type([
Record(FakeTable(), None), fake_table.Record(None),
Record(FakeTable(), None), fake_table.Record(None),
]), "Table1") ]), "Table1")
self.assertEqual(values_type([ self.assertEqual(values_type([
Record(FakeTable(), None), fake_table.Record(None),
Record(FakeTable(), None), fake_table.Record(None),
None, None,
]), "Optional[Table1]") ]), "Optional[Table1]")
self.assertEqual(values_type([ self.assertEqual(values_type([
RecordSet(FakeTable(), None), fake_table.RecordSet(None),
RecordSet(FakeTable(), None), fake_table.RecordSet(None),
]), "List[Table1]") ]), "List[Table1]")
self.assertEqual(values_type([ self.assertEqual(values_type([
RecordSet(FakeTable(), None), fake_table.RecordSet(None),
RecordSet(FakeTable(), None), fake_table.RecordSet(None),
None, None,
]), "Optional[List[Table1]]") ]), "Optional[List[Table1]]")