Coverage for test_e22_passwd_to_csv.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from e22_passwd_to_csv import passwd_to_csv
2import pytest
5@pytest.fixture
6def passwd_file(tmp_path):
7 f = tmp_path / 'passwd'
8 f.write_text('''
9root:x:0:0:root:/root:/bin/bash
10daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
11bin:x:2:2:bin:/bin:/usr/sbin/nologin
12sys:x:3:3:sys:/dev:/usr/sbin/nologin
13sync:x:4:65534:sync:/bin:/bin/sync
14games:x:5:60:games:/usr/games:/usr/sbin/nologin
15man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
16lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
17mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
18atara:x:1004:1005:Atara Lerner-Friedman,,,:/home/atara:/bin/bash
19shikma:x:1005:1006:Shikma Lerner-Friedman,,,:/home/shikma:/bin/bash
20amotz:x:1006:1007:Amotz Lerner-Friedman,,,:/home/amotz:/bin/bash
21''')
22 return f
25def test_passwd_to_csv(passwd_file):
26 passwd_to_csv(passwd_file, 'output.csv')
28 csv_content = open('output.csv').read()
29 assert len(csv_content) == 95
30 assert csv_content.splitlines()[0] == 'root\t0'
31 assert csv_content.splitlines()[-1] == 'amotz\t1006'