Ejemplo n.º 1
0
 def test_multiply_fail_with_char_input(self):
     tester = app.test_client(self)
     response = tester.get('/multiply?value1=1&value2=3r')
     self.assertEqual(response.status_code, 406)
     self.assertEqual(response.data, 'Variables should be integer.')
Ejemplo n.º 2
0
 def test_multiply_success_with_both_float(self):
     tester = app.test_client(self)
     response = tester.get('/multiply?value1=2.5&value2=2.5')
     self.assertEqual(json.loads(response.data), 6.25)
Ejemplo n.º 3
0
 def test_multiply_success_with_float_int_1(self):
     tester = app.test_client(self)
     response = tester.get('/multiply?value1=1.0&value2=2.0')
     self.assertEqual(json.loads(response.data), 2.0)
Ejemplo n.º 4
0
 def test_multiply_success_with_both_int(self):
     tester = app.test_client(self)
     response = tester.get('/multiply?value1=1&value2=1')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), 1)
Ejemplo n.º 5
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
Ejemplo n.º 6
0
 def test_minus_success_with_float_int(self):
     tester = app.test_client(self)
     response = tester.get('/minus?value1=1.1&value2=2')
     self.assertEqual(json.loads(response.data), -0.9)
Ejemplo n.º 7
0
 def test_minus_fail_with_missing_necessary_var(self):
     tester = app.test_client(self)
     response = tester.get('/minus?value1=1')
     self.assertEqual(response.status_code, 406)
     self.assertEqual(response.data, 'Missing necessary variables input.')
Ejemplo n.º 8
0
 def test_sum_success_with_both_float(self):
     tester = app.test_client(self)
     response = tester.get('/sum?value1=1.1&value2=1.2')
     self.assertEqual(json.loads(response.data), 2.3)
Ejemplo n.º 9
0
 def test_divide_fail_with_invalidate_denominator(self):
     tester = app.test_client(self)
     response = tester.get('/divide?value1=1&value2=0')
     # pprint.pprint(response)
     self.assertEqual(response.status_code, 406)
     self.assertEqual(response.data, 'Value2 could not be zero.')
Ejemplo n.º 10
0
 def test_divide_success_when_result_is_float(self):
     tester = app.test_client(self)
     response = tester.get('/divide?value1=10&value2=4')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(json.loads(response.data), 2.5)
Ejemplo n.º 11
0
 def test_divide_success_with_float_int_1(self):
     tester = app.test_client(self)
     response = tester.get('/divide?value1=1.0&value2=2.0')
     self.assertEqual(json.loads(response.data), 0.5)
Ejemplo n.º 12
0
 def test_divide_success_with_both_float(self):
     tester = app.test_client(self)
     response = tester.get('/divide?value1=6.25&value2=2.5')
     self.assertEqual(json.loads(response.data), 2.5)