hsparql 0.2.6 → 0.2.7
raw patch · 2 files changed
+101/−3 lines, 2 filesdep ~rdf4hPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: rdf4h
API changes (from Hackage documentation)
Files
hsparql.cabal view
@@ -1,6 +1,6 @@ Name: hsparql Homepage: https://github.com/robstewart57/hsparql-Version: 0.2.6+Version: 0.2.7 Synopsis: A SPARQL query generator and DSL, and a client to query a SPARQL server. Category: Database Description:@@ -27,7 +27,7 @@ , HTTP >= 4 , mtl , xml- , rdf4h >= 1.3.1+ , rdf4h >= 1.3.4 , bytestring , MissingH , network@@ -39,7 +39,7 @@ type: exitcode-stdio-1.0 main-is: AllTests.hs build-depends: hsparql- , rdf4h >= 1.3.1+ , rdf4h >= 1.3.4 , base , text , containers@@ -51,6 +51,7 @@ , warp >= 3.0.1 , network-uri hs-source-dirs: Database, tests+ other-modules: Database.HSparql.ConnectionTest extensions: OverloadedStrings, FlexibleInstances source-repository head
+ tests/Database/HSparql/ConnectionTest.hs view
@@ -0,0 +1,97 @@+module Database.HSparql.ConnectionTest ( testSuite ) where++import Test.Framework (testGroup)+import Test.Framework.Providers.HUnit+import Test.HUnit++import qualified Data.Map as Map+import qualified Data.Text as T+import qualified Data.RDF as RDF+import qualified Data.RDF.TriplesGraph as G++import Database.HSparql.Connection+import Database.HSparql.QueryGenerator++testSuite = [+ testGroup "Database.HSparql.Connection tests" [+ testCase "selectQuery" test_selectQuery+ , testCase "askQuery" test_askQuery+ , testCase "constructQuery" test_constructQuery+ , testCase "describeQuery" test_describeQuery+ ]+ ]++test_selectQuery =+ let expectedBVars = Just [ [ Bound $ RDF.lnode $ RDF.plainLL "Kazehakase" "en" ]+ , [ Bound $ RDF.lnode $ RDF.plainLL "Netscape Browser" "en" ]+ , [ Bound $ RDF.lnode $ RDF.plainLL "SlimBrowser" "en" ]+ ]+ in do+ bvars <- selectQuery endPoint query+ assertEqual "bound variables" expectedBVars bvars++ where endPoint = "http://localhost:3000"+ query = do+ resource <- prefix "dbprop" (iriRef "http://dbpedia.org/resource/")+ dbpprop <- prefix "dbpedia" (iriRef "http://dbpedia.org/property/")+ foaf <- prefix "foaf" (iriRef "http://xmlns.com/foaf/0.1/")++ x <- var+ name <- var++ triple x (dbpprop .:. "genre") (resource .:. "Web_browser")+ triple x (foaf .:. "name") name++ return SelectQuery { queryVars = [name] }++test_askQuery = do+ bool <- askQuery endPoint query+ assertBool "invalid" bool++ where endPoint = "http://localhost:3000"+ query = do+ resource <- prefix "dbpedia" (iriRef "http://dbpedia.org/resource/")+ dbprop <- prefix "dbprop" (iriRef "http://dbpedia.org/property/")++ x <- var+ ask <- askTriple x (dbprop .:. "genre") (resource .:. "Web_browser")++ return AskQuery { queryAsk = [ask] }++test_constructQuery =+ let expectedGraph :: G.TriplesGraph+ expectedGraph = G.mkRdf expectedTriples Nothing (RDF.PrefixMappings Map.empty)+ expectedTriples = [ RDF.Triple (RDF.unode "http://dbpedia.org/resource/Kazehakase")+ (RDF.unode "http://www.example.com/hasName")+ (RDF.lnode $ RDF.plainLL "Kazehakase" "en") ]+ in do+ graph <- constructQuery endPoint query :: IO G.TriplesGraph+ assertBool "RDF does not include the constructed triple" $ RDF.isIsomorphic expectedGraph graph++ where endPoint = "http://localhost:3000"+ query = do+ resource <- prefix "dbpedia" (iriRef "http://dbpedia.org/resource/")+ dbpprop <- prefix "dbprop" (iriRef "http://dbpedia.org/property/")+ foaf <- prefix "foaf" (iriRef "http://xmlns.com/foaf/0.1/")+ example <- prefix "example" (iriRef "http://www.example.com/")++ x <- var+ name <- var++ construct <- constructTriple x (example .:. "hasName") name+ triple x (dbpprop .:. "genre") (resource .:. "Web_browser")+ triple x (foaf .:. "name") name++ return ConstructQuery { queryConstructs = [construct] }++test_describeQuery =+ let expectedNode = RDF.unode "http://dbpedia.org/resource/Edinburgh"+ in do+ graph <- describeQuery endPoint query :: IO G.TriplesGraph+ assertBool "RDF does not include the required node" $ RDF.rdfContainsNode graph expectedNode++ where endPoint = "http://localhost:3000"+ query = do+ resource <- prefix "dbpedia" (iriRef "http://dbpedia.org/resource/")+ uri <- describeIRI (resource .:. "Edinburgh")+ return DescribeQuery { queryDescribe = uri }