コード例 #1
0
def test_encode_user_area__block_with_json():
    obj = { 'filtered-authors': [ 17, 4711 ], 'annat': 'Räksmörgås' }
    blocks = { b"jskom": json.dumps(obj, sort_keys=True).encode('utf-8') }
    
    ua = encode_user_area(blocks)
    
    assert ua == b'8H 5Hjskom 70H{"annat": "R\u00e4ksm\u00f6rg\u00e5s", "filtered-authors": [17, 4711]}'
コード例 #2
0
def test_encode_user_area__example():
    blocks = {
        b"common": b"",
        b"elisp": b"32Hkom-auto-confirm-new-conferences 3Hnil\n 22Hcreated-texts-are-read 1H0"
        }
    
    ua = encode_user_area(blocks)
    
    assert ua == b"17H 6Hcommon 5Helisp 0H 72H32Hkom-auto-confirm-new-conferences 3Hnil\n 22Hcreated-texts-are-read 1H0"
コード例 #3
0
def test_encode_user_area__blocks_are_put_in_alphabetical_order():
    blocks = { b"common": b"c", b"jskom": b"j", b"elisp": b"e"}
    
    ua = encode_user_area(blocks)
    
    assert ua == b"25H 6Hcommon 5Helisp 5Hjskom 1Hc 1He 1Hj"
コード例 #4
0
def test_encode_user_area__one_block_with_one_empty_hollerith_string():
    blocks = { b"common": b"0H"}
    
    ua = encode_user_area(blocks)
    
    assert ua == b"9H 6Hcommon 2H0H"
コード例 #5
0
def test_encode_user_area__one_block_with_empty_value():
    blocks = { b"common": b""}
    
    ua = encode_user_area(blocks)
    
    assert ua == b"9H 6Hcommon 0H"
コード例 #6
0
def test_encode_user_area__empty_ua():
    blocks = {}
    
    ua = encode_user_area(blocks)
    
    assert ua == b"0H"