コード例 #1
0
def test_from_json_malformed_string():
    data = {
        'username': '******',
        'api_key': 'api_key',
    }
    with pytest.raises(UserFormatError):
        User.from_json(json.dumps(data) + '}')
コード例 #2
0
def test_from_json():
    data = {
        'username': '******',
        'api_key': 'api_key',
    }
    user = User.from_json(json.dumps(data))
    assert user.username == 'username'
    assert user.api_key == 'api_key'
コード例 #3
0
def test_symmetry():
    user = User(username='******', api_key='api_key')
    assert User.from_json(user.to_json()) == user
コード例 #4
0
def test_from_json_incomplete_data():
    data = {
        'username': '******',
    }
    with pytest.raises(UserFormatError):
        User.from_json(json.dumps(data))