def test_file_equality(self): """Tests for GDFile == GDFile""" s1 = GDScene(GDResourceSection()) s2 = GDScene(GDResourceSection()) self.assertEqual(s1, s2) resource = s1.find_section("resource") resource["key"] = "value" self.assertNotEqual(s1, s2)
def test_remove_section(self): """Test GDScene.remove_section""" scene = GDFile() res = scene.add_ext_resource("res://Other.tscn", "PackedScene") result = scene.remove_section(GDResourceSection()) self.assertFalse(result) self.assertEqual(len(scene.get_sections()), 1) result = scene.remove_section(res) self.assertTrue(result) self.assertEqual(len(scene.get_sections()), 0)
def test_addremove_sub_res(self): """Test adding and removing a sub_resource""" scene = GDResource() res = scene.add_sub_resource("CircleShape2D") self.assertEqual(res.id, 1) res2 = scene.add_sub_resource("AnimationNodeAnimation") self.assertEqual(res2.id, 2) resource = GDResourceSection(shape=res2.reference) scene.add_section(resource) s = scene.find_sub_resource(type="CircleShape2D") scene.remove_section(s) scene.renumber_resource_ids() s = scene.find_section("sub_resource") self.assertEqual(s.id, 1) self.assertEqual(resource["shape"], s.reference)
def test_all_data_types(self): """Run the parsing test cases""" res = GDResource() res.add_section( GDResourceSection( list=[1, 2.0, "string"], map={"key": ["nested", GDObject("Vector2", 1, 1)]}, empty=None, )) self.assertEqual( str(res), """[gd_resource load_steps=1 format=2] [resource] list = [ 1, 2.0, "string" ] map = { "key": [ "nested", Vector2( 1, 1 ) ] } empty = null """, )