# Path: openid/kvform.py
# _LOGGER = logging.getLogger(__name__)
# class KVFormError(ValueError):
# def seqToKV(seq, strict=False):
#     def err(msg):
# def kvToSeq(data, strict=False):
#     def err(msg):
# def dictToKV(d):
# def kvToDict(s):


import unittest
import six
from testfixtures import LogCapture
from openid import kvform
kvdict_cases = [
    # (kvform, parsed dictionary, expected warnings)
    ('', {}, 0),
    ('college:harvey mudd\n', {'college': 'harvey mudd'}, 0),
    ('city:claremont\nstate:CA\n', {'city': 'claremont', 'state': 'CA'}, 0),
    ('is_valid:true\ninvalidate_handle:{HMAC-SHA1:2398410938412093}\n',
     {'is_valid': 'true', 'invalidate_handle': '{HMAC-SHA1:2398410938412093}'}, 0),

    # Warnings from lines with no colon:
    ('x\n', {}, 1),
    ('x\nx\n', {}, 2),
    ('East is least\n', {}, 1),

    # But not from blank lines (because LJ generates them)
    ('x\n\n', {}, 1),

    # Warning from empty key
    (':\n', {'': ''}, 1),
    (':missing key\n', {'': 'missing key'}, 1),

    # Warnings from leading or trailing whitespace in key or value
    (' street:foothill blvd\n', {'street': 'foothill blvd'}, 1),
    ('major: computer science\n', {'major': 'computer science'}, 1),
    (' dorm : east \n', {'dorm': 'east'}, 2),

    # Warnings from missing trailing newline
    ('e^(i*pi)+1:0', {'e^(i*pi)+1': '0'}, 1),
    ('east:west\nnorth:south', {'east': 'west', 'north': 'south'}, 1),
]


# Path: openid/kvform.py
# _LOGGER = logging.getLogger(__name__)
# class KVFormError(ValueError):
# def seqToKV(seq, strict=False):
#     def err(msg):
# def kvToSeq(data, strict=False):
#     def err(msg):
# def dictToKV(d):
# def kvToDict(s):


# Path: openid/test/test_kvform.py
import unittest
import six
from testfixtures import LogCapture
from openid import kvform

kvdict_cases = [
    # (kvform, parsed dictionary, expected warnings)
    ('', {}, 0),
    ('college:harvey mudd\n', {'college': 'harvey mudd'}, 0),
    ('city:claremont\nstate:CA\n', {'city': 'claremont', 'state': 'CA'}, 0),
    ('is_valid:true\ninvalidate_handle:{HMAC-SHA1:2398410938412093}\n',
     {'is_valid': 'true', 'invalidate_handle': '{HMAC-SHA1:2398410938412093}'}, 0),

    # Warnings from lines with no colon:
    ('x\n', {}, 1),
    ('x\nx\n', {}, 2),
    ('East is least\n', {}, 1),

    # But not from blank lines (because LJ generates them)
    ('x\n\n', {}, 1),

    # Warning from empty key
    (':\n', {'': ''}, 1),
    (':missing key\n', {'': 'missing key'}, 1),

    # Warnings from leading or trailing whitespace in key or value
    (' street:foothill blvd\n', {'street': 'foothill blvd'}, 1),
    ('major: computer science\n', {'major': 'computer science'}, 1),
    (' dorm : east \n', {'dorm': 'east'}, 2),

    # Warnings from missing trailing newline
    ('e^(i*pi)+1:0', {'e^(i*pi)+1': '0'}, 1),
    ('east:west\nnorth:south', {'east': 'west', 'north': 'south'}, 1),
]


kvseq_cases = [