示例#1
0
class DeleteBusinessTest(unittest.TestCase):
    """Illustrate test cases to test expected behavior of delete business functionality. """
    def setUp(self):
        """Instantiate the Business class so that it can be reused by other test cases."""

        self.business = Business()

    def test_business_id_existence(self):
        """Test if a KeyError will be raised when the business id does not exist."""

        self.business.create_business(1, 'Cosmas', 'Cosma Tech', 'Nairobi',
                                      'Technology', 'Masters of ecommerce')
        self.assertEqual(self.business.delete_business(4),
                         'Business does not exist')

    def test_empty_business_id(self):
        """Test whether no business id is provided."""

        self.assertEqual(self.business.delete_business(''),
                         'Business ID is required!')

    def test_negative_integer_business_id_raises_ValueError(self):
        """Test if ValueError is raised when business id a negative number."""

        self.assertEqual(self.business.delete_business(-1),
                         'The business ID must be a positive number')

    def test_non_integer_business_id_raises_TypeError(self):
        """Test if TypeError is raised when business id not a number."""

        self.assertEqual(self.business.delete_business('1'),
                         'The business ID must be an number!')
 def delete_business(business_id, user_id):
     """docstring for delete business"""
     return Business.delete_business(business_id, user_id)