Skip to content

Commit

Permalink
docs: Reformat code inside docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iranzo committed Aug 17, 2023
1 parent 89a408c commit 8c7c069
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
32 changes: 17 additions & 15 deletions doc/development/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,29 @@ import shutil
from risu import risu

# To create your own test, update NAME with plugin name and copy this file to test_$NAME.py
NAME = 'httpd_bug_1406417'
NAME = "httpd_bug_1406417"

testplugins = os.path.join(risu.risudir, 'plugins', 'test')
plugins = os.path.join(risu.risudir, 'plugins')
folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'setup')
testplugins = os.path.join(risu.risudir, "plugins", "test")
plugins = os.path.join(risu.risudir, "plugins")
folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), "setup")
uttest = risu.findplugins(folders=[folder], include=[NAME])[0]
us = os.path.basename(uttest)
citplugs = risu.findplugins(folders=[plugins], include=[us])

# Setup commands and expected return codes
rcs = {"pass": risu.RC_OKAY,
"fail": risu.RC_FAILED,
"skipped": risu.RC_SKIPPED,
"info": risu.RC_INFO}
rcs = {
"pass": risu.RC_OKAY,
"fail": risu.RC_FAILED,
"skipped": risu.RC_SKIPPED,
"info": risu.RC_INFO,
}


def runtest(testtype='False'):
def runtest(testtype="False"):
# testtype will be 'pass', 'fail', 'skipped'

# We're iterating against the different UT tests defined in UT-tests folder
tmpdir = tempfile.mkdtemp(prefix='risu-tmp')
tmpdir = tempfile.mkdtemp(prefix="risu-tmp")

# Setup test for 'testtype'
subprocess.call([uttest, uttest, testtype, tmpdir])
Expand All @@ -101,7 +103,7 @@ def runtest(testtype='False'):
res = risu.dorisu(path=tmpdir, plugins=citplugs)

# Get Return code
rc = res[0]['result']['rc']
rc = res[0]["result"]["rc"]

# Remove tmp folder
shutil.rmtree(tmpdir)
Expand All @@ -113,17 +115,17 @@ def runtest(testtype='False'):
class RisuTest(TestCase):
def test_pass(self):
# testtype will be 'pass', 'fail', 'skipped'
testtype = 'pass'
assert runtest(testtype='fail') == rcs[testtype]
testtype = "pass"
assert runtest(testtype="fail") == rcs[testtype]

def test_fail(self):
# testtype will be 'pass', 'fail', 'skipped'
testtype = 'fail'
testtype = "fail"
assert runtest(testtype=testtype) == rcs[testtype]

def test_skip(self):
# testtype will be 'pass', 'fail', 'skipped'
testtype = 'skipped'
testtype = "skipped"
assert runtest(testtype=testtype) == rcs[testtype]
```

Expand Down
5 changes: 3 additions & 2 deletions doc/development/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ As described in plugins documentation, Risu can make use of translated strings.
```py
# Import the _() function
import gettext
localedir = os.environ['TEXTDOMAINDIR']

localedir = os.environ["TEXTDOMAINDIR"]
# This will use system defined LANGUAGE
trad = gettext.translation('risu', localedir, fallback=True)
trad = gettext.translation("risu", localedir, fallback=True)

try:
_ = trad.ugettext
Expand Down
12 changes: 7 additions & 5 deletions doc/development/magui-plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ Magui plugins should conform to the following standards:

returncode = risu.RC_OKAY

message = ''
message = ""
for ourdata in data:
# 'err' in this case should be always equal to the md5sum of the file so that we can report the problem
err = []
for sosreport in ourdata['sosreport']:
err.append(ourdata['sosreport'][sosreport]['err'])
for sosreport in ourdata["sosreport"]:
err.append(ourdata["sosreport"][sosreport]["err"])

if len(sorted(set(err))) != 1:
message = _("Pipeline.yaml contents differ across sosreports, please do check that the contents are the same and shared across the environment to ensure proper behavior.")
message = _(
"Pipeline.yaml contents differ across sosreports, please do check that the contents are the same and shared across the environment to ensure proper behavior."
)
returncode = risu.RC_FAILED

out = ''
out = ""
err = message
return returncode, out, err
```

0 comments on commit 8c7c069

Please sign in to comment.