def test_delete_product_when_product_is_already_deleted( self, mock_product_repo_get ): '''Test delete_product when product is already deleted. ''' # Arrange with self.app.app_context(): mock_product_repo_get.return_value = self.mock_deleted_product product_controller = ProductController(self.request_context) # Act result = product_controller.delete_product(1) # Assert assert result.status_code == 400 assert result.get_json()['msg'] == 'product has already ' \ 'been deleted'
def test_delete_product_when_product_doesnot_exist( self, mock_product_repo_get ): '''Test delete_product when product doesnot exist. ''' # Arrange with self.app.app_context(): mock_product_repo_get.return_value = None product_controller = ProductController(self.request_context) # Act result = product_controller.delete_product(1) # Assert assert result.status_code == 400 assert result.get_json()['msg'] == 'Invalid or incorrect ' \ 'product_id provided'
def test_delete_product_ok_response( self, mock_product_repo_update, mock_product_repo_get ): '''Test delete_product OK response. ''' # Arrange with self.app.app_context(): mock_product_repo_get.return_value = self.mock_product mock_product_repo_update.return_value = self.mock_product product_controller = ProductController(self.request_context) # Act result = product_controller.delete_product(1) # Assert assert result.status_code == 200 assert result.get_json()['msg'] == 'product deleted'