File size: 1,505 Bytes
703e6fc
 
 
 
 
 
 
d1c021a
703e6fc
 
d1c021a
703e6fc
 
 
 
d1c021a
703e6fc
 
 
d1c021a
703e6fc
 
 
 
d1c021a
703e6fc
 
 
d1c021a
703e6fc
 
 
 
d1c021a
703e6fc
 
 
d1c021a
703e6fc
 
 
 
d1c021a
703e6fc
 
 
d1c021a
703e6fc
 
d1c021a
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
import json

from extract import extract

def test_pure_string():
    inp = 'abc'
    token, user, redirect, info = extract(inp)
    assert token == inp
    assert user is None
    assert redirect is None
    assert info is None

def test_json_format_01():
    inp_s = '{"a":"b"}'
    token, user, redirect, info = extract(inp_s)
    inp = json.loads(inp_s)
    assert token == None
    assert user == None
    assert redirect is None
    assert info == inp

def test_json_format_02():
    inp_s = '{"token":"b"}'
    token, user, redirect, info = extract(inp_s)
    inp = json.loads(inp_s)
    assert token == inp['token']
    assert user == None
    assert redirect is None
    assert info == inp

def test_json_format_03():
    inp_s = '{"user":"xb"}'
    token, user, redirect, info = extract(inp_s)
    inp = json.loads(inp_s)
    assert token == None
    assert user == inp['user']
    assert redirect is None
    assert info == inp

def test_json_format_04():
    inp_s = '{"user":"t1", "token":"t2"}'
    token, user, redirect, info = extract(inp_s)
    inp = json.loads(inp_s)
    assert token == inp['token']
    assert user == inp['user']
    assert redirect is None
    assert info == inp

def test_json_format_05():
    inp_s = '{"user":"t1", "token":"t2", "redirect":"xx"}'
    token, user, redirect, info = extract(inp_s)
    inp = json.loads(inp_s)
    assert token == inp['token']
    assert user == inp['user']
    assert redirect == inp['redirect']
    assert info == inp