from __future__ import print_function

import sys, utils

utils.ensure_tempdir()
utils.close_all()

proj = projects.create(utils.temp("infotestproject"))

assert not proj.has_project_info, "project_info present."

info = proj.get_project_info()

assert info.is_project_info, "created object is no project_info."
assert proj.get_project_info, "project_info missing."
assert not info.generate_accessors, "accessor generation before"
assert info.version == None, "version before"
assert not info.released
assert not info.default_namespace
assert not info.author

info.change_accessor_generation(True)

info.company = "3S Test company"
info.title = "Script Test Project"
info.version = (0, 8, 15, 4711)
info.default_namespace = "testproject"
info.author = "Python von Scriptinger"
info.description = "Beschreibung"

# now we set a custom value...
info.values["SpecialDeviceId"] = "PLC0815_4711"

info.released = True;

proj.save()

projpath = proj.path;
proj.close()

proj = projects.open(projpath)

info = proj.get_project_info()

assert info.generate_accessors, "accessor generation after"
assert info.company == "3S Test company"
assert info.title == "Script Test Project"
assert info.version == Version(0, 8, 15, 4711)
assert info.default_namespace == "testproject"
assert info.author == "Python von Scriptinger"
assert info.description == "Beschreibung"
assert info.released
assert info.values["SpecialDeviceId"] == "PLC0815_4711"

for item in info.values:
	print(item)

print("proj finished.")
