Browse Source

added test for returning False from read-function with dialog as well as corresponding functionality

remotes/origin/feature/feature-read-math-functions
fdai7763 11 months ago
parent
commit
9efc7edf83
  1. 13
      src/main/py/read_math_function.py
  2. 7
      src/test/py/test_read_math_function.py

13
src/main/py/read_math_function.py

@ -1,3 +1,16 @@
def read_math_function():
type = "kein Wert"
while(type != "x"):
print("c - Konstanten")
print("v - Funktionen mit Variablen mit konstanten Vorfaktoren (Demnächst verfügbar)")
print("p - Funktionen, die aus Produkten bestehen (Demnächst verfügbar)")
print("k - verkettete Funktionen (Demnächst verfügbar)")
print("x - Ich möchte nichts mehr einlesen lassen")
type = input("Zur Zeit können nur Konstanten eingelesen werden. Bitte geben Sie den Typ ihrer Funktion ein:" )
if type == "x":
return False
def simplify_constant(type, value): def simplify_constant(type, value):
if type != "c": if type != "c":
return False return False

7
src/test/py/test_read_math_function.py

@ -1,6 +1,6 @@
import unittest import unittest
from src.main.py.read_math_function import * from src.main.py.read_math_function import *
from unittest.mock import patch
class read_function(unittest.TestCase): class read_function(unittest.TestCase):
def test_constant_without_calculation(self): def test_constant_without_calculation(self):
@ -24,5 +24,10 @@ class read_function(unittest.TestCase):
def test_constant_string_not_allowed_decision(self): def test_constant_string_not_allowed_decision(self):
self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False) self.assertEqual(simplify_constant("c", "42^(2)+1-3*4/3x"), False)
@patch('builtins.input', side_effect=["x"])
def test_read_math_function_false_if_enter_x(self, mock_input):
result = read_math_function()
self.assertFalse(result)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Loading…
Cancel
Save