rsudp.test
(test helpers)¶
New in version 0.4.3.
The test module. Here are the currently available tests, descriptions, and their initial state:
TEST = {
# permissions
'p_log_dir': ['log directory ', False],
'p_log_std': ['stdout logging ', False],
'p_log_file': ['logging to file ', False],
'p_output_dirs': ['output directory structure ', False],
'p_screenshot_dir': ['screenshot directory ', False],
'p_data_dir': ['data directory ', False],
# network
'n_port': ['port ', False],
'n_internet': ['internet ', False],
'n_inventory': ['inventory (RS FDSN server) ', False],
# core
'x_packetize': ['packetizing data ', False],
'x_send': ['sending data ', False],
'x_data': ['receiving data ', False],
'x_masterqueue': ['master queue ', False],
'x_processing': ['processing data ', False],
'x_ALARM': ['ALARM message ', False],
'x_RESET': ['RESET message ', False],
'x_IMGPATH': ['IMGPATH message ', False],
'x_TERM': ['TERM message ', False],
# dependencies
'd_pydub': ['pydub dependencies ', False],
'd_matplotlib': ['matplotlib backend ', False],
# consumers
'c_plot': ['plot ', False],
'c_write': ['miniSEED write ', False],
'c_miniseed': ['miniSEED data ', False],
'c_print': ['print data ', False],
'c_alerton': ['alert trigger on ', False],
'c_alertoff': ['alert trigger off ', False],
'c_play': ['play sound ', False],
'c_img': ['screenshot exists ', False],
'c_tweet': ['Twitter text message ', False],
'c_tweetimg': ['Twitter image message ', False],
'c_telegram': ['Telegram text message ', False],
'c_telegramimg': ['Telegram image ', False],
'c_forward': ['forwarding ', False],
'c_rsam': ['RSAM transmission ', False],
'c_custom': ['custom code execution ', False],
}
Note
If you wish to add your own consumer module, the easiest way to test
its functionality is to follow the instructions in
Testing your module, then add the relevant test to this dictionary.
Then, you would import the rsudp.test.TEST
variable
and modify the test result (TEST['your_test'][1] = True
)
if the test passed.
If your module is set not to start by default, and you are using the
default settings file for testing, you will need to set
settings['your_module']['enabled'] = True
in
rsudp.test.make_test_settings()
prior to running the tests.
-
rsudp.test.
cancel_tests
(settings, MPL, plot, quiet)¶ Cancel some tests if they don’t need to be run.
Parameters: Return type: Returns: settings dictionary to test with
-
rsudp.test.
datadir_permissions
(testdir)¶ Test write permissions in the data directory (
./data
by default)Parameters: testdir (str) – The directory to test permissions for Return type: bool Returns: the output of rsudp.test.permissions()
-
rsudp.test.
is_connected
(hostname)¶ Test for an internet connection.
Parameters: hostname (str) – The hostname to test with Return type: bool Returns: True
if connection is successful,False
otherwise
-
rsudp.test.
logdir_permissions
(logdir='/tmp/rsudp')¶ Test write permissions in the log directory (
/tmp/rsudp
by default)Parameters: logdir (str) – The log directory to test permissions for Return type: bool Returns: the output of rsudp.test.permissions()
-
rsudp.test.
make_test_settings
(settings, inet=False)¶ Get the default settings and return settings for testing.
The default settings are modified in the following way:
Setting Value settings['settings']['station']
'R24FA'
settings['printdata']['enabled']
True
settings['alert']['threshold']
2
settings['alert']['reset']
0.5
settings['alert']['lowpass']
9
settings['alert']['highpass']
0.8
settings['plot']['channels']
['all']
settings['plot']['duration']
60
settings['plot']['deconvolve']
True
settings['plot']['units']
'CHAN'
settings['plot']['eq_screenshots']
True
settings['write']['enabled']
True
settings['write']['channels']
['all']
settings['tweets']['enabled']
True
settings['telegram']['enabled']
True
settings['alertsound']['enabled']
True
settings['rsam']['enabled']
True
settings['rsam']['debug']
True
settings['rsam']['interval']
10
Note
If there is no internet connection detected, the station name will default to
'Z0000'
so that no time is wasted trying to download an inventory from the Raspberry Shake FDSN service.Parameters: - settings (dict) – settings dictionary (will be modified from Default settings)
- inet (bool) – whether or not the internet test passed
Return type: Returns: settings dictionary to test with
-
rsudp.test.
permissions
(dp)¶ Test write permissions for the specified directory.
Parameters: dp (str) – the directory path to test permissions for Return type: bool Returns: if True
, the test was successful,False
otherwise
-
rsudp.test.
ss_permissions
(testdir)¶ Test write permissions in the screenshots directory (
./screenshots
by default)Parameters: testdir (str) – The directory to test permissions for Return type: bool Returns: the output of rsudp.test.permissions()