import unittest
from steam import vdf

class SyntaxTestCase(unittest.TestCase):
    # Deserialization
    UNQUOTED_VDF = """
    node
    {
        key value
    }
    """

    QUOTED_VDF = """
    "node"
    {
        "key" "value"
    }
    """

    MACRO_UNQUOTED_VDF = """
    node
    {
        key value [$MACRO]
    }
    """

    MACRO_QUOTED_VDF = """
    "node"
    {
        "key" "value" [$MACRO]
    }
    """

    COMMENT_QUOTED_VDF = """
    "node"
    {
        // Hi I'm a comment.
        "key" "value" [$MACRO]
    }
    """

    SUBNODE_QUOTED_VDF = """
    "node"
    {
        "subnode"
        {
            "key" "value"
        }
    }
    """

    MIXED_VDF = """
    node
    {
        "key" value
        key2 "value"
        "key3" "value" [$MACRO]

        // Comment
        "subnode" [$MACRO]
        {
            key value
        }

        "key4" "value"
    }
    """

    MULTIKEY_KV = """
    node
    {
        "key" "k1v1"
        "key" "k1v2"
        "key" "k1v3"

        "key2" "k2v1"

        "key3" "k3v1"
        "key3" "k3v2"
    }
    """

    MULTIKEY_KNODE = """
    node
    {
        "key" {
            "name" "k1v1"
            "extra" ":D"
        }
        "key" {
            "name" "k1v2"
            "extra" ":!"
        }
        "key" {
            "name"  "k1v3"
            "extra" ":O"
        }

        "key2" {
            "name" "k2v1"
            "extra" "I'm lonely"
        }

        "key3" {
            "name" "k3v1"
            "extra" {
                "smiley" ":O"
                "comment" "Wow!"
            }
        }

        "key3" {
            "name" "k3v2"
            "extra" {
                "smiley" ":Z"
                "comment" "BZZ!"
            }
        }
    }
    """

    # Expectations
    EXPECTED_DICT = {
            u"node": {
                u"key": u"value"
                }
            }

    EXPECTED_SUBNODE_DICT = {
            u"node": {
                u"subnode": {
                    u"key": u"value"
                    }
                }