import unittest
from mock import patch
from Calculator import Calculator
from MyExceptions import *

class TestCalculator(unittest.TestCase):
    #Testing Addition Function
    def test_check_addition_two_float_give_me_their_sum(self):
        calculator = Calculator()
        value1 = 2.13
        value2 = -4.12
        sum = -1.99
        self.assertAlmostEqual(calculator.Addition(value1,value2), sum)

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2=2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_addtion_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2="second_string"
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)


    #Testing Divide Function
    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1,value2), sum)

    def test_check_division_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2=2
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2="second_string"
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1=4
        value2=0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    #Testing Logarithm Function
    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1,value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1=-1
        value2=2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2)

    def test_check_if_value2_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1=3
        value2=-3
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2)

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1=1
        value2=1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    #Testing Derivative Function using moc
    @patch("sympy.diff", return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)), my_mock(value1, value2))

if __name__=='__main__':
    unittest.main(exit=False)
017bd01f1101fd330225582e46007edc8913dbdf
<mask token>


class TestCalculator(unittest.TestCase):
    <mask token>

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)
    <mask token>

    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1, value2), sum)
    <mask token>

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 4
        value2 = 0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1, value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = -1
        value2 = 2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )
    <mask token>

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1 = 1
        value2 = 1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    @patch('sympy.diff', return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)),
            my_mock(value1, value2))


<mask token>

<mask token>


class TestCalculator(unittest.TestCase):
    <mask token>

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)
    <mask token>

    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1, value2), sum)

    def test_check_division_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 4
        value2 = 0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1, value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = -1
        value2 = 2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )
    <mask token>

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1 = 1
        value2 = 1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    @patch('sympy.diff', return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)),
            my_mock(value1, value2))


<mask token>

<mask token>


class TestCalculator(unittest.TestCase):
    <mask token>

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_addtion_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1, value2), sum)

    def test_check_division_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 4
        value2 = 0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1, value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = -1
        value2 = 2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )

    def test_check_if_value2_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 3
        value2 = -3
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1 = 1
        value2 = 1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    @patch('sympy.diff', return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)),
            my_mock(value1, value2))


<mask token>

<mask token>


class TestCalculator(unittest.TestCase):

    def test_check_addition_two_float_give_me_their_sum(self):
        calculator = Calculator()
        value1 = 2.13
        value2 = -4.12
        sum = -1.99
        self.assertAlmostEqual(calculator.Addition(value1, value2), sum)

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_addtion_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1, value2), sum)

    def test_check_division_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 2
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1 = 'string'
        value2 = 'second_string'
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 4
        value2 = 0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1, value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = -1
        value2 = 2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )

    def test_check_if_value2_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1 = 3
        value2 = -3
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2
            )

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1 = 1
        value2 = 1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    @patch('sympy.diff', return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)),
            my_mock(value1, value2))


if __name__ == '__main__':
    unittest.main(exit=False)

import unittest
from mock import patch
from Calculator import Calculator
from MyExceptions import *

class TestCalculator(unittest.TestCase):
    #Testing Addition Function
    def test_check_addition_two_float_give_me_their_sum(self):
        calculator = Calculator()
        value1 = 2.13
        value2 = -4.12
        sum = -1.99
        self.assertAlmostEqual(calculator.Addition(value1,value2), sum)

    def test_check_addtion_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2=2
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)

    def test_check_addtion_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2="second_string"
        self.assertRaises(itsNotNumber, calculator.Addition, value1, value2)


    #Testing Divide Function
    def test_check_division_two_float_give_me_their_quotient(self):
        calculator = Calculator()
        value1 = 4.2
        value2 = -2.1
        sum = -2
        self.assertAlmostEqual(calculator.Divide(value1,value2), sum)

    def test_check_division_string_and_int_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2=2
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_string_and_string_raises_exception(self):
        calculator = Calculator()
        value1="string"
        value2="second_string"
        self.assertRaises(itsNotNumber, calculator.Divide, value1, value2)

    def test_check_division_per_zero_raises_exception(self):
        calculator = Calculator()
        value1=4
        value2=0
        self.assertRaises(isZero, calculator.Divide, value1, value2)

    #Testing Logarithm Function
    def test_check_logarithm_two_float_give_me_result(self):
        calculator = Calculator()
        value1 = 2
        value2 = 2
        sum = 1
        self.assertAlmostEqual(calculator.Logarithm(value1,value2), sum)

    def test_check_if_value1_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1=-1
        value2=2
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2)

    def test_check_if_value2_lover_than_zero_raises_exception(self):
        calculator = Calculator()
        value1=3
        value2=-3
        self.assertRaises(isLoverThanZero, calculator.Logarithm, value1, value2)

    def test_check_value1_is_one_raises_exception(self):
        calculator = Calculator()
        value1=1
        value2=1
        self.assertRaises(isOne, calculator.Logarithm, value1, value2)

    #Testing Derivative Function using moc
    @patch("sympy.diff", return_value='2*x')
    def test_check_derivative_return_good_result(self, my_mock):
        calculator = Calculator()
        value1 = 'x**2'
        value2 = 'x'
        self.assertEqual(str(calculator.Derivative(value1, value2)), my_mock(value1, value2))

if __name__=='__main__':
    unittest.main(exit=False)