Skip to content

Commit

Permalink
adds queries
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Oct 31, 2020
1 parent 2ba74d2 commit cdde6fa
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/test_Acronyms.py
Expand Up @@ -6,7 +6,9 @@
import unittest
from ptp.wikicfp import WikiCFP
from storage.config import StoreMode
from storage.query import Query
import re

class TestAcronyms(unittest.TestCase):


Expand All @@ -18,13 +20,17 @@ def tearDown(self):
pass


def getWikiCFPDB(self):
wikiCFP=WikiCFP()
em=wikiCFP.em
sqlDB=em.getSQLDB(em.getCacheFile(em.config, StoreMode.SQL))
return sqlDB

def testAcronyms(self):
'''
test Acronyms
'''
wikiCFP=WikiCFP()
em=wikiCFP.em
sqlDB=em.getSQLDB(em.getCacheFile(em.config, StoreMode.SQL))
sqlDB=self.getWikiCFPDB()
acronymRecords=sqlDB.query("select acronym from event_wikicfp")
print ("total acronyms: %d" % len(acronymRecords))
limit=81966
Expand All @@ -38,6 +44,26 @@ def testAcronyms(self):
print ("%s:%s" % ('✅' if matches else '❌' ,acronym))
print("%d/%d (%5.1f%%) matches for %s" % (count,limit,count/limit*100,regex))

def testQueries(self):
'''
test Queries
'''
sqlDB=self.getWikiCFPDB()
queries=[
{"name":"order of CFPs","query":"select eventId,acronym,year,url from event_wikicfp limit 10"},
{"name":"cfps per year", "query": """select count(*) as perYear,year
from event_wikicfp
group by year
order by 2"""},]
for query in queries:
dbQuery=Query(query['name'],query['query'],"sql")
listOfDicts=sqlDB.query(dbQuery.query)
markup="=== %s ===\n" % (query['name'])
markup+=dbQuery.asWikiSourceMarkup()
markup+=dbQuery.asWikiMarkup(listOfDicts)
print (markup)



if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
Expand Down

0 comments on commit cdde6fa

Please sign in to comment.