# Tests for the DeviceObject functionality.

import utils, System
utils.ensure_tempdir()
utils.close_all()
    
print "Opening the example project."
proj = projects.open(utils.data("LibManTest.project"))

print "Trying to find library manager"
libman = proj.find("Library Manager", True)[0]

print "found:", libman
assert libman.is_libman, "libman is no libman!"

print "Checking whether device is no libman:"
assert not proj.find("CoDeSys_SoftMotion_Win_V3")[0].is_libman, "device is libman!"

print "*** libs currently in project: ***"
for lib in libman.get_libraries(True):
    print "lib: ", lib
print "*** libs ***"

print "now adding some libs."
libman.add_library("Standard, 3.4.1.0 (System)")
libman.add_placeholder("Standard64", "Standard64, 3.4.1.0 (System)")

print "*** libs currently in project: ***"
for lib in libman.get_libraries(True):
    print "lib: ", lib
print "*** libs ***"

print "Now removing a library"
libman.remove_library("#Standard64")

print "*** libs currently in project: ***"
for lib in libman.get_libraries(True):
    print "lib: ", lib
print "*** libs ***"

print "script finished."
