mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-09 19:12:59 +00:00
Fix python codestyle
This commit is contained in:
@@ -70,23 +70,25 @@ def test_nb_user_change(container):
|
||||
running_container = container.run(
|
||||
tty=True,
|
||||
user="root",
|
||||
environment=[f"NB_USER={nb_user}",
|
||||
"CHOWN_HOME=yes"],
|
||||
environment=[
|
||||
f"NB_USER={nb_user}",
|
||||
"CHOWN_HOME=yes"
|
||||
],
|
||||
working_dir=f"/home/{nb_user}",
|
||||
command=['start.sh', 'bash', '-c', 'sleep infinity']
|
||||
)
|
||||
|
||||
|
||||
LOGGER.info(f"Checking if the user is changed to {nb_user} by the start script ...")
|
||||
output = running_container.logs(stdout=True).decode("utf-8")
|
||||
assert f"Set username to: {nb_user}" in output, f"User is not changed to {nb_user}"
|
||||
|
||||
assert f"Set username to: {nb_user}" in output, f"User is not changed to {nb_user}"
|
||||
|
||||
LOGGER.info(f"Checking {nb_user} id ...")
|
||||
command = "id"
|
||||
expected_output = f"uid=1000({nb_user}) gid=100(users) groups=100(users)"
|
||||
cmd = running_container.exec_run(command, user=nb_user)
|
||||
output = cmd.output.decode("utf-8").strip("\n")
|
||||
assert output == expected_output, f"Bad user {output}, expected {expected_output}"
|
||||
|
||||
|
||||
LOGGER.info(f"Checking if {nb_user} owns his home folder ...")
|
||||
command = f'stat -c "%U %G" /home/{nb_user}/'
|
||||
expected_output = f"{nb_user} users"
|
||||
@@ -100,10 +102,11 @@ def test_chown_extra(container):
|
||||
c = container.run(
|
||||
tty=True,
|
||||
user='root',
|
||||
environment=['NB_UID=1010',
|
||||
'NB_GID=101',
|
||||
'CHOWN_EXTRA=/opt/conda',
|
||||
'CHOWN_EXTRA_OPTS=-R',
|
||||
environment=[
|
||||
'NB_UID=1010',
|
||||
'NB_GID=101',
|
||||
'CHOWN_EXTRA=/opt/conda',
|
||||
'CHOWN_EXTRA_OPTS=-R'
|
||||
],
|
||||
command=['start.sh', 'bash', '-c', 'stat -c \'%n:%u:%g\' /opt/conda/LICENSE.txt']
|
||||
)
|
||||
@@ -113,13 +116,14 @@ def test_chown_extra(container):
|
||||
|
||||
|
||||
def test_chown_home(container):
|
||||
"""Container should change the NB_USER home directory owner and
|
||||
"""Container should change the NB_USER home directory owner and
|
||||
group to the current value of NB_UID and NB_GID."""
|
||||
c = container.run(
|
||||
tty=True,
|
||||
user='root',
|
||||
environment=['CHOWN_HOME=yes',
|
||||
'CHOWN_HOME_OPTS=-R',
|
||||
environment=[
|
||||
'CHOWN_HOME=yes',
|
||||
'CHOWN_HOME_OPTS=-R'
|
||||
],
|
||||
command=['start.sh', 'bash', '-c', 'chown root:root /home/jovyan && ls -alsh /home']
|
||||
)
|
||||
|
Reference in New Issue
Block a user