def test_get_formula_terms_unparseable_formula(self): """Does get_formula_terms handle an unparseable formula?""" calculated_field = DocumentationFieldFactory(credit=self.credit, type='calculated') calculated_field.formula = 'value = (bogus }[' formula_terms = calculated_field.get_formula_terms() self.assertItemsEqual([], formula_terms)
def test_get_formula_terms_empty_formula(self): """Does get_formula_terms handle an empty formula?""" calculated_field = DocumentationFieldFactory(credit=self.credit, type='calculated') calculated_field.formula = '' formula_terms = calculated_field.get_formula_terms() self.assertItemsEqual([], formula_terms)
def test_get_formula_terms_calculated_field(self): """Does get_formula_terms handle calculated fields?""" calculated_field = DocumentationFieldFactory(credit=self.credit, type='calculated') calculated_field.formula = 'value = A + B + C / D * (E / F)' formula_terms = calculated_field.get_formula_terms() self.assertItemsEqual(['value', 'A', 'B', 'C', 'D', 'E', 'F'], formula_terms)