#!/usr/share/ucs-test/runner python
## desc: computerroom module time settings
## roles: [domaincontroller_master, domaincontroller_slave]
## tags: [apptest, ucsschool]
## exposure: dangerous
## packages: [ucs-school-umc-computerroom]

from essential.computerroom import Room, Computers
from univention.lib.umc_connection import UMCConnection
import univention.testing.ucr as ucr_test
import univention.testing.ucsschool as utu


def main():
	with utu.UCSTestSchool() as schoolenv:
		with ucr_test.UCSTestConfigRegistry() as ucr:
			school, oudn = schoolenv.create_ou(name_edudc=ucr.get('hostname'))
			tea, tea_dn = schoolenv.create_user(school, is_teacher=True)
			open_ldap_co = schoolenv.open_ldap_connection()

			# importing computers
			computers = Computers(open_ldap_co, school, 2, 0, 0)
			created_computers = computers.create()
			computers_dns = computers.get_dns(created_computers)

			# computer rooms contains the created computers
			room = Room(school, host_members=computers_dns)
			schoolenv.create_computerroom(
					school,
					name=room.name,
					description=room.description,
					host_members=room.host_members
					)
			umc_connection = UMCConnection(ucr.get('hostname'))
			umc_connection.auth(tea, 'univention')

			room.test_time_settings(umc_connection)


if __name__ == '__main__':
	main()
