def test_has_object_permission_has_permission(self, mock_has_permission): mock_has_permission.return_value = True result = has_object_permission(self.product_type, 'Product_Type_View') self.assertTrue(result) mock_has_permission.assert_called_with(None, self.product_type, Permissions.Product_Type_View)
def test_has_object_permission_has_permission(self, mock_current_user, mock_has_permission): mock_has_permission.return_value = True mock_current_user.return_value = self.user result = has_object_permission(self.product_type, 'Product_Type_View') self.assertTrue(result) mock_has_permission.assert_called_with(self.user, self.product_type, Permissions.Product_Type_View) mock_current_user.assert_called_once()
def test_has_object_permission_wrong_permission(self): with self.assertRaises(KeyError): result = has_object_permission(self.product_type, 'Test')
def test_has_object_permission_legacy(self): result = has_object_permission(self.product_type, Permissions.Product_Type_View) self.assertFalse(result)