How to use isBlank method in fMBT

Best Python code snippet using fMBT_python

queryHelper.py

Source:queryHelper.py Github

copy

Full Screen

...116 && !STRSTARTS(STR(?x), "http://www.w3.org/1999/02/22-rdf-syntax-ns")117 && !STRSTARTS(STR(?x), "http://www.w3.org/2000/01/rdf-schema")118 && !STRSTARTS(STR(?x), "http://www.w3.org/2001/XMLSchema")119 && !STRSTARTS(STR(?x), "http://www.w3.org/XML/1998/namespace")120 && (!isBlank(?x))121 ) .122 } 123 ORDER BY ?x124 """)125 return list(qres)126 #legacy127 128 def getAllClassesFromInstancesToo(self):129 """130 by default, obscure all RDF/RDFS/OWL/XML stuff131 NOTE: this is more expensive!132 133 added: { ?y rdf:type ?x } 134 """135 qres = self.rdfgraph.query(136 """SELECT DISTINCT ?x ?c137 WHERE {138 { 139 { ?x a owl:Class } 140 union 141 { ?x a rdfs:Class }142 union 143 { ?x rdfs:subClassOf ?y }144 union 145 { ?z rdfs:subClassOf ?x }146 union 147 { ?y rdf:type ?x } 148 union 149 { ?y rdfs:domain ?x }150 union 151 { ?y rdfs:range ?x } 152 } . 153 154 ?x a ?c155 156 FILTER(157 !STRSTARTS(STR(?x), "http://www.w3.org/2002/07/owl")158 && !STRSTARTS(STR(?x), "http://www.w3.org/1999/02/22-rdf-syntax-ns")159 && !STRSTARTS(STR(?x), "http://www.w3.org/2000/01/rdf-schema")160 && !STRSTARTS(STR(?x), "http://www.w3.org/2001/XMLSchema")161 && !STRSTARTS(STR(?x), "http://www.w3.org/XML/1998/namespace")162 && (!isBlank(?x))163 ) .164 } 165 ORDER BY ?x166 """)167 return list(qres)168 169 def getClassInstances(self, aURI):170 aURI = unicode(aURI)171 qres = self.rdfgraph.query(172 """SELECT DISTINCT ?x173 WHERE {174 { ?x rdf:type <%s> } 175 FILTER (!isBlank(?x))176 } ORDER BY ?x 177 """ % (aURI))178 return list(qres)179 def getClassInstancesCount(self, aURI):180 aURI = unicode(aURI)181 qres = self.rdfgraph.query(182 """SELECT (COUNT(?x) AS ?count )183 WHERE {184 { ?x rdf:type <%s> } 185 FILTER (!isBlank(?x))186 } ORDER BY ?x 187 """ % (aURI))188 try:189 return int(list(qres)[0][0])190 except:191 printDebug("Error with <getClassInstancesCount>")192 return 0193 194 def getClassDirectSupers(self, aURI):195 aURI = unicode(aURI)196 qres = self.rdfgraph.query(197 """SELECT DISTINCT ?x198 WHERE {199 { <%s> rdfs:subClassOf ?x } 200 FILTER (!isBlank(?x))201 } ORDER BY ?x 202 """ % (aURI))203 return list(qres)204 def getClassDirectSubs(self, aURI):205 """ 206 2015-06-03: currenlty not used, inferred from above207 """208 aURI = unicode(aURI)209 qres = self.rdfgraph.query(210 """SELECT DISTINCT ?x211 WHERE {212 { ?x rdfs:subClassOf <%s> } 213 FILTER (!isBlank(?x))214 } 215 """ % (aURI))216 return list(qres)217 218 def getClassAllSupers(self, aURI):219 """ 220 note: requires SPARQL 1.1 221 2015-06-04: currenlty not used, inferred from above222 """223 aURI = unicode(aURI)224 try:225 qres = self.rdfgraph.query(226 """SELECT DISTINCT ?x227 WHERE {228 { <%s> rdfs:subClassOf+ ?x } 229 FILTER (!isBlank(?x))230 } 231 """ % (aURI))232 except:233 printDebug("... warning: the 'getClassAllSupers' query failed (maybe missing SPARQL 1.1 support?)")234 qres = []235 return list(qres) 236 def getClassAllSubs(self, aURI):237 """ 238 note: requires SPARQL 1.1 239 2015-06-04: currenlty not used, inferred from above240 """241 aURI = unicode(aURI)242 try:243 qres = self.rdfgraph.query(244 """SELECT DISTINCT ?x245 WHERE {246 { ?x rdfs:subClassOf+ <%s> } 247 FILTER (!isBlank(?x))248 } 249 """ % (aURI))250 except:251 printDebug("... warning: the 'getClassAllSubs' query failed (maybe missing SPARQL 1.1 support?)")252 qres = []253 return list(qres) 254 255 256 # .................. 257 # RDF PROPERTIES 258 # ..................259 260 261 # NOTE this kinf of query could be expanded to classes too!!! 262 def getAllProperties(self):263 qres = self.rdfgraph.query(264 """SELECT ?x ?c WHERE {265 {266 { ?x a rdf:Property } 267 UNION 268 { ?x a owl:ObjectProperty }269 UNION 270 { ?x a owl:DatatypeProperty }271 UNION 272 { ?x a owl:AnnotationProperty }273 } . 274 ?x a ?c 275 FILTER(!isBlank(?x)276 ) .277 } ORDER BY ?c ?x278 """)279 return list(qres)280 281 282 def getPropDirectSupers(self, aURI):283 aURI = unicode(aURI)284 qres = self.rdfgraph.query(285 """SELECT DISTINCT ?x286 WHERE {287 { <%s> rdfs:subPropertyOf ?x } 288 FILTER (!isBlank(?x))289 } ORDER BY ?x 290 """ % (aURI))291 return list(qres) 292 293 294 def getPropAllSupers(self, aURI):295 """ 296 note: requires SPARQL 1.1 297 2015-06-04: currenlty not used, inferred from above298 """299 aURI = unicode(aURI)300 try:301 qres = self.rdfgraph.query(302 """SELECT DISTINCT ?x303 WHERE {304 { <%s> rdfs:subPropertyOf+ ?x } 305 FILTER (!isBlank(?x))306 } 307 """ % (aURI))308 except:309 printDebug("... warning: the 'getPropAllSupers' query failed (maybe missing SPARQL 1.1 support?)")310 qres = []311 return list(qres) 312 def getPropAllSubs(self, aURI):313 """ 314 note: requires SPARQL 1.1 315 2015-06-04: currenlty not used, inferred from above316 """317 aURI = unicode(aURI)318 try:319 qres = self.rdfgraph.query(320 """SELECT DISTINCT ?x321 WHERE {322 { ?x rdfs:subPropertyOf+ <%s> } 323 FILTER (!isBlank(?x))324 } 325 """ % (aURI))326 except:327 printDebug("... warning: the 'getPropAllSubs' query failed (maybe missing SPARQL 1.1 support?)")328 qres = []329 return list(qres)330 331 # .................. 332 # SKOS : 2015-08-19333 # ..................334 335 def getSKOSInstances(self):336 qres = self.rdfgraph.query(337 """SELECT DISTINCT ?x338 WHERE {339 { ?x rdf:type skos:Concept } 340 FILTER (!isBlank(?x))341 } ORDER BY ?x 342 """)343 return list(qres)344 345 346 def getSKOSDirectSupers(self, aURI):347 aURI = unicode(aURI)348 qres = self.rdfgraph.query(349 """SELECT DISTINCT ?x350 WHERE {351 { 352 { <%s> skos:broader ?x }353 UNION 354 { ?x skos:narrower <%s> }355 } 356 FILTER (!isBlank(?x))357 } ORDER BY ?x 358 """ % (aURI, aURI))359 return list(qres)360 def getSKOSDirectSubs(self, aURI):361 """ 362 2015-08-19: currenlty not used, inferred from above363 """364 aURI = unicode(aURI)365 qres = self.rdfgraph.query(366 """SELECT DISTINCT ?x367 WHERE {368 { 369 { ?x skos:broader <%s> }370 UNION 371 { <%s> skos:narrower ?s }372 }373 FILTER (!isBlank(?x))374 } 375 """ % (aURI, aURI))...

Full Screen

Full Screen

CurrentSystemDao.py

Source:CurrentSystemDao.py Github

copy

Full Screen

1# coding=UTF-82#根据搜索内容查询产品分页3from util import Resp4from util.BaseDao import executeQuery5from util.Util import isblank6def SearchProduct(search_text, page):7 params = []8 sql = """ SELECT c.id as category_id, category_name, p.id as product_id9 , p.product_name, p.product_long_name, p.hsh_property_id, p.product_eol10 ,p.product_view_url, p.create_time as create_time from hsh_category c INNER JOIN hsh_product p ON c.id = p.hsh_category_id 11 where p.product_eol=0 """ 12 if isblank(search_text):13 sql = sql + " and c.category_name like %s "14 params.append(search_text)15 if isblank(search_text):16 sql = sql + " or p.product_name like %s "17 params.append(search_text)18 if isblank(search_text):19 sql = sql + " or p.product_long_name like %s "20 params.append(search_text)21 sql = sql + " ORDER BY p.create_time DESC limit %s,%s"22 params.append((int(page)-1) * Resp.PAGESIZE)23 params.append(Resp.PAGESIZE)24 return executeQuery(sql, params, "")25#根据搜索内容查询产品数量26def SearchProductCount(search_text):27 params = []28 sql = " SELECT count(*) count from hsh_category c INNER JOIN hsh_product p ON c.id = p.hsh_category_id where p.product_eol=0 " 29 if isblank(search_text):30 sql = sql + " and c.category_name like %s "31 params.append(search_text)32 if isblank(search_text):33 sql = sql + " or p.product_name like %s "34 params.append(search_text)35 if isblank(search_text):36 sql = sql + " or p.product_long_name like %s "37 params.append(search_text)38 return executeQuery(sql, params, "json")39#根据搜索内容查询EOL产品数量40def SearchEOLProductCount(search_text):41 params = []42 sql = " SELECT count(*) count from hsh_category c INNER JOIN hsh_product p ON c.id = p.hsh_category_id where p.product_eol=1 " 43 if isblank(search_text):44 sql = sql + " and c.category_name like %s "45 params.append(search_text)46 if isblank(search_text):47 sql = sql + " or p.product_name like %s "48 params.append(search_text)49 if isblank(search_text):50 sql = sql + " or p.product_long_name like %s "51 params.append(search_text)52 return executeQuery(sql, params, "json")53def SearchEOLProduct(search_text, page):54 params = []55 sql = """ SELECT c.id as category_id, category_name, p.id as product_id56 , p.product_name, p.product_long_name, p.hsh_property_id, p.product_eol57 ,p.product_view_url, p.create_time as create_time from hsh_category c INNER JOIN hsh_product p ON c.id = p.hsh_category_id 58 where p.product_eol=1 """ 59 if isblank(search_text):60 sql = sql + " and c.category_name like %s "61 params.append(search_text)62 if isblank(search_text):63 sql = sql + " or p.product_name like %s "64 params.append(search_text)65 if isblank(search_text):66 sql = sql + " or p.product_long_name like %s "67 params.append(search_text)68 sql = sql + " ORDER BY p.create_time DESC limit %s,%s"69 params.append((int(page)-1) * Resp.PAGESIZE)70 params.append(Resp.PAGESIZE)...

Full Screen

Full Screen

StringHelper_test.py

Source:StringHelper_test.py Github

copy

Full Screen

2import sys3import time4import pytest5import feedwork.utils.StringHelper as stru6def test_isBlank():7 assert stru.isBlank(None)8 assert stru.isBlank("")9 assert stru.isBlank(" ")10 assert stru.isBlank("\t \r\n \r \n")11 assert not stru.isBlank("a")12 with pytest.raises(AssertionError):13 stru.isBlank(1)14def test_isNotBlank():15 assert not stru.isNotBlank(None)16 assert not stru.isNotBlank("")17 assert not stru.isNotBlank(" ")18 assert not stru.isNotBlank("\t \r\n \r \n")19 assert stru.isNotBlank("a")20 with pytest.raises(AssertionError):21 stru.isNotBlank(1)22if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful