Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/sharedra.../oldrads/test
File: conftest_autosuspend.py
import pytest
[0] Fix | Delete
import ConfigParser
[1] Fix | Delete
from datetime import datetime, timedelta
[2] Fix | Delete
[3] Fix | Delete
[4] Fix | Delete
@pytest.fixture
[5] Fix | Delete
def reset():
[6] Fix | Delete
def inner(user):
[7] Fix | Delete
try:
[8] Fix | Delete
sh.Command('unsuspend_user')(user)
[9] Fix | Delete
except Exception:
[10] Fix | Delete
pass
[11] Fix | Delete
[12] Fix | Delete
return inner
[13] Fix | Delete
[14] Fix | Delete
[15] Fix | Delete
def yaml_data1(file):
[16] Fix | Delete
if 'autosuspend.yaml' in file:
[17] Fix | Delete
data = {
[18] Fix | Delete
'argosy6': {
[19] Fix | Delete
'suspensions': [
[20] Fix | Delete
(datetime.now() - timedelta(days=90)).strftime("%s"),
[21] Fix | Delete
],
[22] Fix | Delete
'warnings': [
[23] Fix | Delete
(datetime.now() - timedelta(seconds=90)).strftime("%s"),
[24] Fix | Delete
],
[25] Fix | Delete
}
[26] Fix | Delete
}
[27] Fix | Delete
return data
[28] Fix | Delete
elif 'sa_interval.yaml' in file:
[29] Fix | Delete
return {
[30] Fix | Delete
'argosy6': 0.1,
[31] Fix | Delete
'ausr': 100,
[32] Fix | Delete
'clyde': '8999.1',
[33] Fix | Delete
'herrew5': 0.0,
[34] Fix | Delete
'baduser': 0.0,
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
[38] Fix | Delete
def sa_data1(*x, **y):
[39] Fix | Delete
sa_ln = "\n".join(
[40] Fix | Delete
[
[41] Fix | Delete
"argosy6 3 0.00re 150.00cp 27499k",
[42] Fix | Delete
"fooba 6 0.12re 9000.01cp 2799k",
[43] Fix | Delete
"clyde 4 0.12re 9000.01cp 2799k",
[44] Fix | Delete
"herrew5 4 0.12re 15.00cp 2799k",
[45] Fix | Delete
"baduser 4 0.12re 9000.01cp 2799k",
[46] Fix | Delete
]
[47] Fix | Delete
)
[48] Fix | Delete
return sa_ln
[49] Fix | Delete
[50] Fix | Delete
[51] Fix | Delete
@pytest.fixture
[52] Fix | Delete
def tmpdir_config(tmpdir):
[53] Fix | Delete
conf = tmpdir.mkdir('etc').join('autosuspend.cfg')
[54] Fix | Delete
opsdir = tmpdir.mkdir('ops')
[55] Fix | Delete
logfile = tmpdir.mkdir('log').join('suspension.log')
[56] Fix | Delete
fixture_config = ConfigParser.ConfigParser()
[57] Fix | Delete
fixture_config.add_section('settings')
[58] Fix | Delete
fixture_config.set('settings', 'opfiles', str(opsdir))
[59] Fix | Delete
fixture_config.set('settings', 'suspension_log', str(logfile))
[60] Fix | Delete
with open(str(conf), 'w') as fp:
[61] Fix | Delete
fixture_config.write(fp)
[62] Fix | Delete
[63] Fix | Delete
return str(conf)
[64] Fix | Delete
[65] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function