# Path: tests/data/test_data.py

# 
# Path: tests/models/student.py
# class Student(Model):
#     # def __init__(self, **kwargs):
#         # We define model relations in __init__ method, because Python parser raises a NameError
#         # if we refer to a not yet defined class in body of another class.
#         # self.contact_info = ContactInfo()
#         # super(Student, self).__init__(**kwargs)
#     # contact_info = ContactInfo()
# 
#     # def row_level_access(self):
#     #     self.objects = self.objects.filter(user_in=self._context.user['id'],)
# 
# 
#     number = field.String("Student No", index=True)
#     pno = field.String("TC No", index=True)
#     name = field.String("First Name", type='text_tr', index=False)
#     surname = field.String("Last Name", type='text_tr', index=False)
#     join_date = field.Date("Join Date", index=True)
#     bio = field.Text("Biography", index=True)
# 
#     class AuthInfo(Node):
#         username = field.String("Username")
#         email = field.String("Email")
#         password = field.String("Password", index=False)
# 
#     class Lectures(ListNode):
#         name = field.String(type='text_tr')
#         code = field.String(required=False)
#         credit = field.Integer(default=0)
#         role = Role('Role_1', index=True)
# 
#         class NodeInListNode(Node):
#             foo = field.String(index=False)
# 
#         class Exams(ListNode):
#             type = field.String(index=False)
#             date = field.Date(index=False)
#             point = field.Integer(index=False)
# 
#         class Attendance(ListNode):
#             date = field.Date(index=False)
#             hour = field.Integer(index=False)
#             attended = field.Boolean(default=False, index=False)
# 
#     class Lecturer(ListNode):
#         role = Role('Role_2', index=True)


from tests.data.test_data import data, clean_data
from tests.models import Student
    # s.timestamp = d['timestamp']
    s.bio = d['bio']
    s.name = d['name']
    s.surname = d['surname']
    s.pno = d['pno']
    s.join_date = data['join_date']
    d = data['auth_info']
    ai = s.AuthInfo()
    ai.email = d['email']
    ai.password = d['password']
    ai.username = d['username']
    s.Lecturer(**data['lecturer'][0])
    for ld in data['lectures']:
        lecture = s.Lectures()
        lecture.code = ld['code']
        lecture.credit = ld['credit']
        lecture.name = ld['name']
        milm = lecture.NodeInListNode()
        milm.foo = ld['node_in_list_node']['foo']
        for atd in ld['attendance']:
            attendance = lecture.Attendance()
            attendance.attended = atd['attended']
            attendance.date = atd['date']
            attendance.hour = atd['hour']
        for exam in ld['exams']:
            exm = lecture.Exams()
            exm.date = exam['date']
            exm.point = exam['point']
            exm.type = exam['type']
    clean_value = s.clean_value()

# Path: tests/data/test_data.py

# 
# Path: tests/models/student.py
# class Student(Model):
#     # def __init__(self, **kwargs):
#         # We define model relations in __init__ method, because Python parser raises a NameError
#         # if we refer to a not yet defined class in body of another class.
#         # self.contact_info = ContactInfo()
#         # super(Student, self).__init__(**kwargs)
#     # contact_info = ContactInfo()
# 
#     # def row_level_access(self):
#     #     self.objects = self.objects.filter(user_in=self._context.user['id'],)
# 
# 
#     number = field.String("Student No", index=True)
#     pno = field.String("TC No", index=True)
#     name = field.String("First Name", type='text_tr', index=False)
#     surname = field.String("Last Name", type='text_tr', index=False)
#     join_date = field.Date("Join Date", index=True)
#     bio = field.Text("Biography", index=True)
# 
#     class AuthInfo(Node):
#         username = field.String("Username")
#         email = field.String("Email")
#         password = field.String("Password", index=False)
# 
#     class Lectures(ListNode):
#         name = field.String(type='text_tr')
#         code = field.String(required=False)
#         credit = field.Integer(default=0)
#         role = Role('Role_1', index=True)
# 
#         class NodeInListNode(Node):
#             foo = field.String(index=False)
# 
#         class Exams(ListNode):
#             type = field.String(index=False)
#             date = field.Date(index=False)
#             point = field.Integer(index=False)
# 
#         class Attendance(ListNode):
#             date = field.Date(index=False)
#             hour = field.Integer(index=False)
#             attended = field.Boolean(default=False, index=False)
# 
#     class Lecturer(ListNode):
#         role = Role('Role_2', index=True)


# Path: tests/test_serialize_model.py
from tests.data.test_data import data, clean_data
from tests.models import Student

    # s.timestamp = d['timestamp']
    s.bio = d['bio']
    s.name = d['name']
    s.surname = d['surname']
    s.pno = d['pno']
    s.join_date = data['join_date']
    d = data['auth_info']
    ai = s.AuthInfo()
    ai.email = d['email']
    ai.password = d['password']
    ai.username = d['username']
    s.Lecturer(**data['lecturer'][0])
    for ld in data['lectures']:
        lecture = s.Lectures()
        lecture.code = ld['code']
        lecture.credit = ld['credit']
        lecture.name = ld['name']
        milm = lecture.NodeInListNode()
        milm.foo = ld['node_in_list_node']['foo']
        for atd in ld['attendance']:
            attendance = lecture.Attendance()
            attendance.attended = atd['attended']
            attendance.date = atd['date']
            attendance.hour = atd['hour']
        for exam in ld['exams']:
            exm = lecture.Exams()
            exm.date = exam['date']
            exm.point = exam['point']
            exm.type = exam['type']
    clean_value = s.clean_value()

    clean_data['timestamp'] = clean_value['timestamp']