packages feed

servant-py 0.1.1.0 → 0.1.1.1

raw patch · 4 files changed

+23/−22 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -1,5 +1,7 @@ # servant-py +[![Build Status](https://dev.azure.com/eraker62/servant-py/_apis/build/status/erewok.servant-py?branchName=master)](https://dev.azure.com/eraker62/servant-py/_build/latest?definitionId=1?branchName=master)+ This library lets you derive automatically Python functions that let you query each endpoint of a *servant* webservice.  Currently, the only supported method for generating requests is via the `requests` library, which is the recommended way to generate HTTP requests in the Python world (even among Python core devs).
servant-py.cabal view
@@ -1,5 +1,5 @@ name:                servant-py-version:             0.1.1.0+version:             0.1.1.1 synopsis:            Automatically derive python functions to query servant webservices. description:   Automatically derive python functions to query servant webservices.
src/Servant/PY/Internal.hs view
@@ -262,15 +262,14 @@ makePyUrl opts (UnTypedPythonRequest req) offset = makePyUrl' opts req offset  makePyUrl' :: forall f. CommonGeneratorOptions -> Req f -> Text -> Text-makePyUrl' opts req offset = "\"" <> url <> "\""+makePyUrl' opts req offset = "\"" <> url <> "\"" <> withFormattedCaptures offset pathParts   where url = urlPrefix opts <> "/" <> getSegments pathParts-                             <> withFormattedCaptures offset pathParts         pathParts = req ^.. reqUrl.path.traverse  getSegments :: forall f. [Segment f] -> Text getSegments segments = if null segments                        then ""-                       else T.intercalate "/" (map segmentToStr segments) <> "\""+                       else T.intercalate "/" (map segmentToStr segments)  withFormattedCaptures :: Text -> [Segment f] -> Text withFormattedCaptures offset segments = formattedCaptures (capturesToFormatArgs segments)@@ -306,7 +305,7 @@   where args = capturesToFormatArgs $ req ^.. reqUrl.path.traverse  buildDocString' :: forall f. Req f -> CommonGeneratorOptions -> [Text] -> Text -> Text-buildDocString' req opts args returnVal = T.toUpper method <> " \"" <> url <> "\n"+buildDocString' req opts args returnVal = T.toUpper method <> " /" <> url <> "\n"                                                   <> includeArgs <> "\n\n"                                                   <> indent' <> "Returns:\n"                                                   <> indent' <> indent' <> returnVal
test/Servant/PY/InternalSpec.hs view
@@ -102,14 +102,14 @@    describe "functions that operate on Req objects" $ do     let captureList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) captureApi-    -- it "should correctly find captures" $ do-    --   let captured = captures . head $ captureList-    --   captured `shouldBe` ["id", "Name", "hungrig"]+    it "should correctly find captures" $ do+      let captured = captures . head $ map UnTypedPythonRequest captureList+      captured `shouldBe` ["id", "Name", "hungrig"] -    -- let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) testApi-    -- it "should not incorrectly find captures" $ do-    --   let captured = captures . head $ reqList-    --   captured `shouldBe` []+    let reqList = listFromAPI (Proxy :: Proxy NoTypes) (Proxy :: Proxy NoContent) testApi+    it "should not incorrectly find captures" $ do+      let captured = captures . head $ map UnTypedPythonRequest reqList+      captured `shouldBe` []      let req = head captureList     let pathParts = req ^.. reqUrl.path.traverse@@ -126,18 +126,18 @@     it "should build a formatted val that ends with parens" $       property $ \s -> T.isSuffixOf (T.pack s <> "))") $ formatBuilder $ T.pack s -    -- it "should build urls properly with / separator" $ do-    --   let pyUrl = makePyUrl customOptions req " "-    --   pyUrl `shouldBe` "\"urlForRequesting:9000/login-with-path-var-and-header/{id}/{Name}/{hungrig}\""-    --                    <> withFormattedCaptures " " pathParts+    it "should build urls properly with / separator" $ do+      let pyUrl = makePyUrl customOptions (UnTypedPythonRequest req) " "+      pyUrl `shouldBe` "\"urlForRequesting:9000/login-with-path-var-and-header/{id}/{Name}/{hungrig}\""+                       <> withFormattedCaptures " " pathParts      it "should do segment-to-str as a plain string for Static" $       segmentToStr (head pathParts) == "login-with-path-var-and-header"     it "should do segment-to-str in formatting braces for a capture" $       segmentToStr (last pathParts) == "{hungrig}"-    -- it "should build a doctstring that looks like a regular Python docstring" $ do-    --   let docstring = buildDocString req customOptions-    --   docstring `shouldContain` "POST"-    --   docstring `shouldContain` makePyUrl' pathParts-    --   docstring `shouldContain` "Args:"-    --   docstring `shouldContain` "Returns:"+    it "should build a doctstring that looks like a regular Python docstring" $ do+      let docstring = buildDocString (UnTypedPythonRequest req) customOptions ""+      docstring `shouldContain` "POST"+      docstring `shouldContain` "/login-with-path-var-and-header/{id}/{Name}/{hungrig}"+      docstring `shouldContain` "Args:"+      docstring `shouldContain` "Returns:"