diff --git a/pyairtable/formulas.py b/pyairtable/formulas.py index 09a40f7c..734a4e4b 100644 --- a/pyairtable/formulas.py +++ b/pyairtable/formulas.py @@ -218,3 +218,53 @@ def LOWER(value: str) -> str: "LOWER(TestValue)" """ return "LOWER({})".format(value) + + +def NOT_EQUAL(left: Any, right: Any) -> str: + """ + Create an inequality assertion + + >>> NOT_EQUAL(2,2) + '2!=2' + """ + return "{}!={}".format(left, right) + + +def LESS_EQUAL(left: Any, right: Any) -> str: + """ + Create a less than assertion + + >>> LESS_EQUAL(2,2) + '2<=2' + """ + return "{}<={}".format(left, right) + + +def GREATER_EQUAL(left: Any, right: Any) -> str: + """ + Create a greater than assertion + + >>> GREATER_EQUAL(2,2) + '2>=2' + """ + return "{}>={}".format(left, right) + + +def LESS(left: Any, right: Any) -> str: + """ + Create a less assertion + + >>> LESS(2,2) + '2<2' + """ + return "{}<{}".format(left, right) + + +def GREATER(left: Any, right: Any) -> str: + """ + Create a greater assertion + + >>> GREATER(2,2) + '2>2' + """ + return "{}>{}".format(left, right) diff --git a/tests/test_formulas.py b/tests/test_formulas.py index 4e36a89d..0736da5a 100644 --- a/tests/test_formulas.py +++ b/tests/test_formulas.py @@ -5,8 +5,13 @@ EQUAL, FIELD, FIND, + GREATER, + GREATER_EQUAL, IF, + LESS, + LESS_EQUAL, LOWER, + NOT_EQUAL, OR, STR_VALUE, escape_quotes, @@ -86,3 +91,23 @@ def test_escape_quotes(text, escaped): def test_lower(): assert LOWER("TestValue") == "LOWER(TestValue)" + + +def test_greater_equal(): + assert GREATER_EQUAL("A", "B") == "A>=B" + + +def test_less_equal(): + assert LESS_EQUAL("A", "B") == "A<=B" + + +def test_greater(): + assert GREATER("A", "B") == "A>B" + + +def test_less(): + assert LESS("A", "B") == "A