IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Procházet zdrojové kódy

Start unit tests for jails.

master
Stanislaw Adaszewski před 4 roky
rodič
revize
0f4d3ab7f9
1 změnil soubory, kde provedl 28 přidání a 0 odebrání
  1. +28
    -0
      tests/test_jail.py

+ 28
- 0
tests/test_jail.py Zobrazit soubor

@@ -0,0 +1,28 @@
from focker.jail import backup_file
import tempfile
import os
def test_backup_file():
with tempfile.TemporaryDirectory() as d:
fname = os.path.join(d, 'dummy.conf')
with open(fname, 'w') as f:
f.write('init')
nbackups = 10
for i in range(15):
backup_file(fname, nbackups=nbackups, chmod=0o640)
with open(fname, 'w') as f:
f.write(str(i))
fname = os.path.join(d, 'dummy.conf')
with open(fname, 'r') as f:
assert f.read() == '14'
for i in range(nbackups):
fname = os.path.join(d, 'dummy.conf.%d' % i)
assert os.path.exists(fname)
with open(fname, 'r') as f:
if i < 5:
assert f.read() == str(i + 9)
else:
assert f.read() == str(i - 1)

Načítá se…
Zrušit
Uložit