-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d473a5
commit 4a030e3
Showing
5 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Created on 2023-11-22 | ||
@author: wf | ||
""" | ||
|
||
from ngwidgets.widgets import Link | ||
from corpus.eventcorpus import EventStorage | ||
|
||
class ConferenceCorpusQueries: | ||
""" | ||
Class for managing and displaying queries related to a conference corpus. | ||
This class provides functionalities for accessing and rendering queries | ||
related to conference data stored in an EventStorage system. | ||
""" | ||
|
||
def __init__(self): | ||
""" | ||
Initialize the ConferenceCorpusQueries instance. | ||
Sets up the query manager by retrieving it from the EventStorage. | ||
""" | ||
self.queryManager = EventStorage.getQueryManager() # Type: QueryManager | ||
|
||
def as_html(self) -> str: | ||
""" | ||
Generate an HTML representation of the queries. | ||
Iterates through the available queries and creates an HTML unordered list | ||
with links to each query. | ||
Returns: | ||
str: HTML string representing the list of queries. | ||
""" | ||
markup = "<ul>" | ||
for queryName in self.queryManager.queriesByName: | ||
url = f"/query/{queryName}" | ||
link = Link.create(url, queryName,url_encode=True) | ||
markup += f"\n <li>{link}" | ||
markup += "\n</ul>" | ||
return markup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Created on 22.11.2023 | ||
@author: wf | ||
This module contains tests for querying the Conference Corpus. | ||
The `TestConferenceCorpusQueries` class extends `Basetest` and provides | ||
methods to test queries against the Conference Corpus. It particularly focuses | ||
on the ability to generate HTML markup from the corpus queries. | ||
""" | ||
|
||
from ngwidgets.basetest import Basetest | ||
from corpus.web.cc_queries import ConferenceCorpusQueries | ||
|
||
class TestConferenceCorpusQueries(Basetest): | ||
"""Test class for querying the Conference Corpus. | ||
This class tests the functionality of ConferenceCorpusQueries, | ||
specifically its ability to convert query results to HTML format. | ||
""" | ||
|
||
def test_cc_queries(self) -> None: | ||
""" | ||
Test the generation of HTML markup from conference corpus queries. | ||
This method checks if the ConferenceCorpusQueries can successfully | ||
convert its query results into HTML format and contains specific | ||
HTML tags indicating a successful conversion. | ||
""" | ||
ccq = ConferenceCorpusQueries() | ||
markup = ccq.as_html() | ||
debug = self.debug | ||
# Uncomment the next line to enable debugging output | ||
# debug = True | ||
if debug: | ||
print(markup) | ||
self.assertTrue("<li><a" in markup) # Checking for specific HTML tag in output |