From 803a6c31c9ab0dbd954f3d4400155663fabf21c8 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 11 Sep 2020 14:40:39 +0100 Subject: [PATCH 1/2] miggytest plugin: Tests "for plugins" modules This plugin is designed as a quick test that we are supplying the things we say we will for plugins. * Check that modules are available: sqlite3, shutil, zipfile. * Check that logging works as expected. --- plugins/miggytest.disabled/load.py | 86 ++++++++++++++++++++ plugins/miggytest.disabled/miggytest.db | Bin 0 -> 61440 bytes plugins/miggytest.disabled/subA/__init__.py | 6 ++ 3 files changed, 92 insertions(+) create mode 100644 plugins/miggytest.disabled/load.py create mode 100644 plugins/miggytest.disabled/miggytest.db create mode 100644 plugins/miggytest.disabled/subA/__init__.py diff --git a/plugins/miggytest.disabled/load.py b/plugins/miggytest.disabled/load.py new file mode 100644 index 00000000..23e0dd41 --- /dev/null +++ b/plugins/miggytest.disabled/load.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +# vim: textwidth=0 wrapmargin=0 tabstop=4 shiftwidth=4 softtabstop=4 smartindent smarttab + +import os +import sys +import sqlite3 +import shutil +import zipfile +import logging + +from config import appname + +from subA import subA + +# This could also be returned from plugin_start3() +plugin_name = os.path.basename(os.path.dirname(__file__)) + +# Logger per found plugin, so the folder name is included in +# the logging format. +logger = logging.getLogger(f'{appname}.{plugin_name}') +if not logger.hasHandlers(): + level = logging.INFO # So logger.info(...) is equivalent to print() + + logger.setLevel(level) + logger_channel = logging.StreamHandler() + logger_channel.setLevel(level) + logger_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(module)s:%(lineno)d:%(funcName)s: %(message)s') # noqa: E501 + logger_formatter.default_time_format = '%Y-%m-%d %H:%M:%S' + logger_formatter.default_msec_format = '%s.%03d' + logger_channel.setFormatter(logger_formatter) + logger.addHandler(logger_channel) + + +this = sys.modules[__name__] # For holding module globals +this.DBFILE = 'miggytest.db' +this.mt = None + + +class miggytest(object): + def __init__(self, directory: str): + logger.debug(f'directory = "{directory}') + dbfile = os.path.join(directory, this.DBFILE) + + # Test 'import zipfile' + with zipfile.ZipFile(dbfile + '.zip', 'w') as zip: + if os.path.exists(dbfile): + zip.write(dbfile) + zip.close() + + # Testing 'import shutil' + if os.path.exists(dbfile): + shutil.copyfile(dbfile, dbfile + '.bak') + + # Testing 'import sqlite3' + self.sqlconn = sqlite3.connect(dbfile) + self.sqlc = self.sqlconn.cursor() + try: + self.sqlc.execute('CREATE TABLE entries (timestamp TEXT, cmdrname TEXT, system TEXT, station TEXT, eventtype TEXT)') # noqa: E501 + except sqlite3.OperationalError: + logger.exception('sqlite3.OperationalError when CREATE TABLE entries:') + + def store(self, timestamp: str, cmdrname: str, system: str, station: str, event: str): + logger.debug(f'timestamp = "{timestamp}", cmdr = "{cmdrname}", system = "{system}", station = "{station}", event = "{event}"') # noqa: E501 + self.sqlc.execute('INSERT INTO entries VALUES(?, ?, ?, ?, ?)', (timestamp, cmdrname, system, station, event)) + self.sqlconn.commit() + return None + + +def plugin_start3(plugin_dir: str): + logger.info(f'Folder is {plugin_dir}') + this.mt = miggytest(plugin_dir) + + this.suba = subA(logger) + + this.suba.ping() + + return plugin_name + + +def plugin_stop(): + logger.info('Stopping') + + +def journal_entry(cmdrname: str, is_beta: bool, system: str, station: str, entry: dict, state: dict): + logger.debug(f'cmdr = "{cmdrname}", is_beta = "{is_beta}", system = "{system}", station = "{station}"') + this.mt.store(entry['timestamp'], cmdrname, system, station, entry['event']) diff --git a/plugins/miggytest.disabled/miggytest.db b/plugins/miggytest.disabled/miggytest.db new file mode 100644 index 0000000000000000000000000000000000000000..daf421ce9896ff5f2989a3e8c1647104e2366020 GIT binary patch literal 61440 zcmeI53zQsHnaBJ6tnLN`!T=#N2{8$i$MkehX1WuSOeRUsOlI;P5)w_A%rr@p$xN8( z;Sq>zJ?5~i2&=N-s;DcXyKDpxDk`$5xQj<+m*WG`)x}jHyNV#93qH`@``uezed|_r zbyfH6b9T@692^`@-Cy1M>Q?pl{r_K8@7_67DCS$Qo|-;B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+jYcYYw~)-b`YM=&l2}oa&h8&>ZnabnDA0lUiSMCeDac99ds;#2L}8)S5^GbHo$T zsfSKUC0SyQxFWjyqf?eDOUw~RgvrC5olQ-am?Nf0{m~kkBZdf5b~u}snJh6!>=FK4 z;*;>_64!)3m-r|Axx`H2&n4Che=f0CxN{X^vGC^-n}t7@_$~ao#C_qgz>Zc3Sjv70s#Vzo$`MRs zGEx+N2kMLZd_zvT+VmLFD@^R4N>$>>V-mYs5y}3#r-MIUVPXy*a8rXnhDq#dO*v5# zwBYwEhcS&w;gO~5;2| zfd79iF+cvDxDwCCei8dlbiw;bB9nMq|jcL^pjl_`+y*I86$Iyb+<#2l30q%xhm7?YUF6iv**i&C`8G&grq zg?TxUu+)HESRr5zBrG~$Ev6F#NzwLuI@Ew&U>Yz)a@s}#!qeQmO7pV6F4TaXZyGQ( zFZ(JA9WZ#pPkT)e-Ll+#Eb6 NXm*GWmOehj{{fs>*_QwS literal 0 HcmV?d00001 diff --git a/plugins/miggytest.disabled/subA/__init__.py b/plugins/miggytest.disabled/subA/__init__.py new file mode 100644 index 00000000..acd1a2cb --- /dev/null +++ b/plugins/miggytest.disabled/subA/__init__.py @@ -0,0 +1,6 @@ +class subA: + def __init__(self, logger): + self.logger = logger + + def ping(cls): + cls.logger.info('ping!') From ec5b9fc56114e9c095218fba4259c57f9de22b61 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 22 Sep 2020 14:43:10 +0100 Subject: [PATCH 2/2] Rename miggytest plugin to plugintest. Also now has docstrings and types, and generally passes flake8 and also mypy, with the exception of that 'this' hack not being liked. --- docs/examples/plugintest/SubA/__init__.py | 18 +++++ .../examples/plugintest}/load.py | 69 +++++++++++++----- .../examples/plugintest}/miggytest.db | Bin plugins/miggytest.disabled/subA/__init__.py | 6 -- 4 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 docs/examples/plugintest/SubA/__init__.py rename {plugins/miggytest.disabled => docs/examples/plugintest}/load.py (71%) rename {plugins/miggytest.disabled => docs/examples/plugintest}/miggytest.db (100%) delete mode 100644 plugins/miggytest.disabled/subA/__init__.py diff --git a/docs/examples/plugintest/SubA/__init__.py b/docs/examples/plugintest/SubA/__init__.py new file mode 100644 index 00000000..1630863a --- /dev/null +++ b/docs/examples/plugintest/SubA/__init__.py @@ -0,0 +1,18 @@ +"""Test class logging.""" + +import logging + + +class SubA: + """Simple class to test logging.""" + + def __init__(self, logger: logging.Logger): + self.logger = logger + + def ping(self) -> None: + """ + Log a ping to demonstrate correct logging. + + :return: + """ + self.logger.info('ping!') diff --git a/plugins/miggytest.disabled/load.py b/docs/examples/plugintest/load.py similarity index 71% rename from plugins/miggytest.disabled/load.py rename to docs/examples/plugintest/load.py index 23e0dd41..4a614aa2 100644 --- a/plugins/miggytest.disabled/load.py +++ b/docs/examples/plugintest/load.py @@ -1,17 +1,18 @@ #!/usr/bin/env python # vim: textwidth=0 wrapmargin=0 tabstop=4 shiftwidth=4 softtabstop=4 smartindent smarttab +"""Plugin that tests that modules we bundle for plugins are present and working.""" -import os -import sys -import sqlite3 -import shutil -import zipfile import logging +import os +import shutil +import sqlite3 +import sys +import zipfile + +from SubA import SubA from config import appname -from subA import subA - # This could also be returned from plugin_start3() plugin_name = os.path.basename(os.path.dirname(__file__)) @@ -31,12 +32,14 @@ if not logger.hasHandlers(): logger.addHandler(logger_channel) -this = sys.modules[__name__] # For holding module globals -this.DBFILE = 'miggytest.db' +this = sys.modules[__name__] # For holding module globals +this.DBFILE = 'plugintest.db' this.mt = None -class miggytest(object): +class PluginTest(object): + """Class that performs actual tests on bundled modules.""" + def __init__(self, directory: str): logger.debug(f'directory = "{directory}') dbfile = os.path.join(directory, this.DBFILE) @@ -59,28 +62,60 @@ class miggytest(object): except sqlite3.OperationalError: logger.exception('sqlite3.OperationalError when CREATE TABLE entries:') - def store(self, timestamp: str, cmdrname: str, system: str, station: str, event: str): + def store(self, timestamp: str, cmdrname: str, system: str, station: str, event: str) -> None: + """ + Store the provided data in sqlite database. + + :param timestamp: + :param cmdrname: + :param system: + :param station: + :param event: + :return: None + """ logger.debug(f'timestamp = "{timestamp}", cmdr = "{cmdrname}", system = "{system}", station = "{station}", event = "{event}"') # noqa: E501 self.sqlc.execute('INSERT INTO entries VALUES(?, ?, ?, ?, ?)', (timestamp, cmdrname, system, station, event)) self.sqlconn.commit() return None -def plugin_start3(plugin_dir: str): - logger.info(f'Folder is {plugin_dir}') - this.mt = miggytest(plugin_dir) +def plugin_start3(plugin_dir: str) -> str: + """ + Plugin startup method. - this.suba = subA(logger) + :param plugin_dir: + :return: 'Pretty' name of this plugin. + """ + logger.info(f'Folder is {plugin_dir}') + this.mt = PluginTest(plugin_dir) + + this.suba = SubA(logger) this.suba.ping() return plugin_name -def plugin_stop(): +def plugin_stop() -> None: + """ + Plugin stop method. + + :return: + """ logger.info('Stopping') -def journal_entry(cmdrname: str, is_beta: bool, system: str, station: str, entry: dict, state: dict): +def journal_entry(cmdrname: str, is_beta: bool, system: str, station: str, entry: dict, state: dict) -> None: + """ + Handle the given journal entry. + + :param cmdrname: + :param is_beta: + :param system: + :param station: + :param entry: + :param state: + :return: None + """ logger.debug(f'cmdr = "{cmdrname}", is_beta = "{is_beta}", system = "{system}", station = "{station}"') this.mt.store(entry['timestamp'], cmdrname, system, station, entry['event']) diff --git a/plugins/miggytest.disabled/miggytest.db b/docs/examples/plugintest/miggytest.db similarity index 100% rename from plugins/miggytest.disabled/miggytest.db rename to docs/examples/plugintest/miggytest.db diff --git a/plugins/miggytest.disabled/subA/__init__.py b/plugins/miggytest.disabled/subA/__init__.py deleted file mode 100644 index acd1a2cb..00000000 --- a/plugins/miggytest.disabled/subA/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -class subA: - def __init__(self, logger): - self.logger = logger - - def ping(cls): - cls.logger.info('ping!')