Example #1
0
    def test_date_as_key(self):
        test_string = '''1438.3.6=
            {
                controller="SWE"
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["1438.3.6"]["controller"], "SWE")
Example #2
0
    def test_dict(self):
        test_string = '''
            date="1454.1.1"
            thing="stuff"
            one=1'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["thing"], "stuff")
        self.assertEqual(result["one"], "1")
Example #3
0
    def test_province_int_as_key(self):
        test_string = '''-1=
            {
                name="Stockholm"
                owner="SWE"
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["-1"]["name"], "Stockholm")
Example #4
0
    def test_curly_brace_sub_dict(self):
        test_string = '''player="TUR"
            savegame_version=
            {
                first=1
                second=7
                third=3
                forth=0
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["savegame_version"]["second"], "7")
Example #5
0
    def test_mixed_type_dictionary(self):
        test_string = '''history=
            {
                manpower=3.000
                fort1=yes
                capital="Stockholm"
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["history"]["manpower"], "3.000")
        self.assertEqual(result["history"]["fort1"], 'yes')
        self.assertEqual(result["history"]["capital"], "Stockholm")
Example #6
0
    def test_curly_brace_sub_list(self):
        test_string = '''gameplaysettings=
            {
                setgameplayoptions=
                {
                    1 4 0 0 0 0 0 1 0 1 0 0 
                }
            }'''

        result = Dictionary.parseString(test_string)
        print(result)
        
        self.assertEqual(result["gameplaysettings"]["setgameplayoptions"][1], "4")
Example #7
0
    def test_curly_list_of_identifiers(self):
        test_string = '''gameplaysettings=
            {
                setgameplayoptions=
                {
                   first=1
                   second=1
                   third=1
                }
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["gameplaysettings"]["setgameplayoptions"]["second"], "1")
Example #8
0
    def test_curly_dict_in_value(self):
        test_string = '''player={
                savegame_version=
                {
                    first=1
                    second=7
                    third=3
                    forth=0
                }
            }'''

        result = Dictionary.parseString(test_string)
        self.assertEqual(result["player"]["savegame_version"]["second"], "7")