Skip to content

Commit

Permalink
Change file name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaiMurillo committed Jan 12, 2025
1 parent 95857ea commit 7b91346
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
File renamed without changes.
30 changes: 15 additions & 15 deletions solutions/tests/test_basic_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Author: Ana Isabel Murillo
"""

from solutions.basic_calculator.main import calculate
from solutions.basic_calculator.basic_calculator import calculate
import unittest


Expand All @@ -19,36 +19,36 @@ class TestCalculate(unittest.TestCase):

def test_addition(self):
"""It should correctly add two numbers."""
self.assertEqual(calculate('add', 5, 3), 8.0)
self.assertEqual(calculate('add', -5, -3), -8.0)
self.assertEqual(calculate('add', 0, 5), 5.0)
self.assertEqual(calculate("add", 5, 3), 8.0)
self.assertEqual(calculate("add", -5, -3), -8.0)
self.assertEqual(calculate("add", 0, 5), 5.0)

def test_subtraction(self):
"""It should correctly subtract the second number from the first."""
self.assertEqual(calculate('subtract', 10, 4), 6.0)
self.assertEqual(calculate('subtract', -5, -5), 0.0)
self.assertEqual(calculate('subtract', 0, 5), -5.0)
self.assertEqual(calculate("subtract", 10, 4), 6.0)
self.assertEqual(calculate("subtract", -5, -5), 0.0)
self.assertEqual(calculate("subtract", 0, 5), -5.0)

def test_multiplication(self):
"""It should correctly multiply two numbers."""
self.assertEqual(calculate('multiply', 7, 3), 21.0)
self.assertEqual(calculate('multiply', -2, 3), -6.0)
self.assertEqual(calculate('multiply', 0, 10), 0.0)
self.assertEqual(calculate("multiply", 7, 3), 21.0)
self.assertEqual(calculate("multiply", -2, 3), -6.0)
self.assertEqual(calculate("multiply", 0, 10), 0.0)

def test_division(self):
"""It should correctly divide the first number by the second."""
self.assertEqual(calculate('divide', 9, 3), 3.0)
self.assertEqual(calculate('divide', -6, 3), -2.0)
self.assertAlmostEqual(calculate('divide', 7, 2), 3.5)
self.assertEqual(calculate("divide", 9, 3), 3.0)
self.assertEqual(calculate("divide", -6, 3), -2.0)
self.assertAlmostEqual(calculate("divide", 7, 2), 3.5)

def test_division_by_zero(self):
"""It should raise a ValueError when attempting to divide by zero."""
with self.assertRaises(ValueError) as context:
calculate('divide', 5, 0)
calculate("divide", 5, 0)
self.assertEqual(str(context.exception), "Cannot divide by zero.")

def test_invalid_operation(self):
"""It should raise a ValueError for an invalid operation."""
with self.assertRaises(ValueError) as context:
calculate('invalid_op', 5, 3)
calculate("invalid_op", 5, 3)
self.assertIn("Invalid operation", str(context.exception))

0 comments on commit 7b91346

Please sign in to comment.