aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/resource/ut/lib/test_simple.py
blob: eaac8aa4c48a17442025383156a5701404ae7a83 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import six  # noqa

import library.python.resource as rs 
 
text = b'na gorshke sidel korol\n'
 

def test_find():
    assert rs.find('/qw.txt') == text


def test_iter():
    assert set(rs.iterkeys()).issuperset({'/qw.txt', '/prefix/1.txt', '/prefix/2.txt'})
    assert set(rs.iterkeys(prefix='/prefix/')) == {'/prefix/1.txt', '/prefix/2.txt'}
    assert set(rs.iterkeys(prefix='/prefix/', strip_prefix=True)) == {'1.txt', '2.txt'}
    assert set(rs.iteritems(prefix='/prefix')) == {
        ('/prefix/1.txt', text),
        ('/prefix/2.txt', text),
    }
    assert set(rs.iteritems(prefix='/prefix', strip_prefix=True)) == {
        ('/1.txt', text),
        ('/2.txt', text),
    }


def test_resfs_files():
    assert 'contrib/python/py/.dist-info/METADATA' in set(rs.resfs_files())


def test_resfs_read():
    assert 'Metadata-Version' in rs.resfs_read('contrib/python/py/.dist-info/METADATA').decode('utf-8')