# Path: attendance/models.py
# class SSIDName(models.Model):
#     name = models.CharField(max_length=30)
# 
#     def generate_random_name(self):
#         size = random.randint(10, 17)
#         chars = string.ascii_lowercase + string.digits
#         self.name = ''.join(random.choice(chars) for _ in range(size))
# 
#     def __str__(self):
#         return self.name
# 
# class DailyAttendance(models.Model):
#     """
#     attendance = { "2016": {"user_id": [1, s_time, e_time], "user_id": [0, s_time, e_time]}  }
#     """
#     date = models.DateField()
#     attendance = JSONField()
# 
#     def __str__(self):
#         return str(self.date)


from datetime import datetime
from django.test import TestCase
from attendance.models import SSIDName, DailyAttendance




class DailyAttendanceTest(TestCase):
    def setUp(self):
        self.attendance_json = {1: 0, 2: 0}
        self.daily_attendance = DailyAttendance(date=datetime.now().date(), attendance=self.attendance_json)

    def test_add_attendance(self):
        """
        Tests adding daily attendance
        """
        self.assertEqual(DailyAttendance.objects.count(), 0)
        self.daily_attendance.save()

# Path: attendance/models.py
# class SSIDName(models.Model):
#     name = models.CharField(max_length=30)
# 
#     def generate_random_name(self):
#         size = random.randint(10, 17)
#         chars = string.ascii_lowercase + string.digits
#         self.name = ''.join(random.choice(chars) for _ in range(size))
# 
#     def __str__(self):
#         return self.name
# 
# class DailyAttendance(models.Model):
#     """
#     attendance = { "2016": {"user_id": [1, s_time, e_time], "user_id": [0, s_time, e_time]}  }
#     """
#     date = models.DateField()
#     attendance = JSONField()
# 
#     def __str__(self):
#         return str(self.date)


# Path: attendance/tests.py
from datetime import datetime
from django.test import TestCase
from attendance.models import SSIDName, DailyAttendance





class DailyAttendanceTest(TestCase):
    def setUp(self):
        self.attendance_json = {1: 0, 2: 0}
        self.daily_attendance = DailyAttendance(date=datetime.now().date(), attendance=self.attendance_json)

    def test_add_attendance(self):
        """
        Tests adding daily attendance
        """
        self.assertEqual(DailyAttendance.objects.count(), 0)
        self.daily_attendance.save()

        self.assertEqual(DailyAttendance.objects.count(), 1)