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 fetch             ', False],

    # dependencies
    'd_pydub':              ['pydub dependencies          ', False],
    'd_matplotlib':         ['matplotlib backend          ', False],

    # core
    'c_data':               ['receiving data              ', False],
    'c_processing':         ['processing data             ', False],
    'c_ALARM':              ['ALARM message               ', False],
    'c_RESET':              ['RESET message               ', False],
    'c_IMGPATH':            ['IMGPATH message             ', False],
    'c_TERM':               ['TERM message                ', 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
  • settings (dict) – the dictionary of settings for program execution

  • plot (bool) – whether or not to plot (False == no plot)

  • quiet (bool) – whether or not to play sounds (True == no sound)

Return type

dict

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['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['alertsound']['enabled']

True

settings['rsam']['enabled']

True

settings['rsam']['debug']

True

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

dict

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()


Back to top ↑