mylinux.libs package

Submodules

mylinux.libs.AppErr module

Here are defined all possible application type errors. They are defined to show more info to the user/developer, and to catch errors that hides from developers.

exception mylinux.libs.AppErr.model(message)[source]

Bases: exceptions.Exception

Exception type for model error.

Parameters:

message (str) – Message for error info.

Variables:
  • message (str) – Message for error info.
  • exitCode (int) – Exit code.
__str__()[source]
Returns:Error message.
exception mylinux.libs.AppErr.user(message)[source]

Bases: exceptions.Exception

Exception type for user error.

Parameters:

message (str) – Message for error info.

Variables:
  • message (str) – Message for error info.
  • exitCode (int) – Exit code.
__str__()[source]
Returns:Error message.
exception mylinux.libs.AppErr.developer(message)[source]

Bases: exceptions.Exception

Exception type for developer error.

Parameters:

message (str) – Message for error info.

Variables:
  • message (str) – Message for error info.
  • exitCode (int) – Exit code.
__str__()[source]
Returns:Error message.

mylinux.libs.Assert module

Warning

Every unit test module should have Assert.coverage test in setUp class!

class mylinux.libs.Assert.Assert[source]

Bases: unittest.case.TestCase

Hellper class for adding functionality to unittesting.

Variables:maxDiff (boo) – You want to see max diff of error?
classmethod getErrorMessage(err, replaceChar="'", newChar='')[source]

Getting error message base on python version.

Parameters:
  • err (cls) – Error class.
  • replaceChar (str) – Replace which string in error msg.
  • newChar (str) – Put new string in error msg.
Returns:

Error message string.

coverage(testClass, testClassSkiped, typeRemove, typeElements, typeSkiped)[source]

Custom coverage testing for testing class.

Parameters:
  • testClass (cls) – Test coverage for testing class.
  • testClassSkiped (arr-str) – What methods don’t have testing logic?
  • typeElements (arr-cls) – What class/instance is testClass testing?
  • typeRemove (arr-str) – Remove strings from typeElements example: ‘_Controller’.
  • typeSkiped (arr-str) – What methods testClass don’t want to test?
Raises:
  • ValueError – If typeElements is empty.
  • ValueError – If testClass don’t containes test_ string.
  • ValueError – If test are missing in testClass.
sameDirStructures(dir1, dir2)[source]

Check if dirs have the same structure

Parameters:
  • dir1 (str) – Path to first dir structure.
  • dir2 (str) – Path to second -//-.
Raises:

ValueError – If dirs are diferent.

termCommand(strCommand)[source]

Catching terminal stdout/stderr

Parameters:strCommand (str) – String command to be executed.
Returns:[ True or False, stdout, stderr ] array will return True if no error is catched, else False.

mylinux.libs.decorator module

Here are defined all custom decorators.

mylinux.libs.decorator.overrides(interface_class)[source]

Decorator to override class method

Parameters:interface_class (cls) – Which class is being overrided?
Raises:ValueError – If method is not located in interface_class.
Returns:Method that is overriding interface_class.
mylinux.libs.decorator.override(function)[source]

To visualy see that you are overriding some class method.

Parameters:function (fun) – You can joust do @override and it will pass function in args.
Returns:Method that is overriding interface_class.
class mylinux.libs.decorator.ClassProperty[source]

Bases: property

Make class property (not instance property).

Parameters:property (fun) – You can joust do @ClassProperty and fun will be passed in args.
Returns:Value from property function.

mylinux.libs.e2eData module

class mylinux.libs.e2eData.E2E_data[source]

Hellper class for integration tests.

This class will simulate mylinux data structure for the executing tests.

Variables:

Example of usage:

E2E_data.setUp(
        installed={
                u'package': {
                        u'configState': u'error',
                        u'created': u'%d-%d-%d %d:%d:%d.%d',
                        ...
                },
                ...
        },
        packages={
                'package': {
                        'info': {'class': 'class', ... },
                        'scripts': {
                                'config-purge': 'printf CP...',
                                'config-install': 'printf CI...',
                                ...
                        }
                },
                ...
        }
)

E2E-test-data.tearDown()
filesPath = 'E2E-test-data'
packagesPath = 'E2E-test-data/packages'
scriptsPath = 'E2E-test-data/scripts'
installedPath = 'E2E-test-data/installed.json'
classmethod tearDown()[source]

Remove and clean testing file structure.

classmethod setUp(installed={}, scripts={}, packages={})[source]

Setup testing file structure.

Parameters:
  • installed (dic) – Dictionary if installed data.
  • scripts (dic) – All main scripts names and data.
  • packages (dic) – List package names and his structures.
Raises:

ValueError – If testing structure already exist.

classmethod getData()[source]

Get all data info from filesPath.

Returns:Dictionary of all files in files structure.

Example of returning data:

{
        '<ROOT>/installed.json': {
                u'package': {
                        u'configState': u'None',
                        u'created': u'%d-%d-%d %d:%d:%d.%d',
                        u'lastChange': u'%d-%d-%d %d:%d:%d.%d',
                        u'packageState': u'None'},
                }
        },
        '<ROOT>/packages/package/info.json': {
                u'class': u'class',
                u'info': u'info',
                u'module': u'module'
        },
        '<ROOT>/packages/package/scripts/config-install': ['printf CI...'],
        '<ROOT>/packages/package/scripts/config-purge': ['printf CP...'],
        '<ROOT>/packages/package/scripts/package-install': ['printf PI...'],
        '<ROOT>/packages/package/scripts/package-purge': ['printf PP...'],
        '<ROOT>/packages/package/scripts/test.py': ['printf T...']
}

Module contents

Other Parameters:
 
  • module_Assert (mod)
  • module_e2eData (mod)
  • decorator (all-mix)
  • AppErr (all-cls)
  • Assert (cla)
  • E2E_data (cla)