예제 #1
0
    def setUp(self):
        self.user = User(username="******")
        self.user.save()
        self.second_user = User(username="******")
        self.second_user.save()
        self.teacher_user = User(username="******")
        self.teacher_user.save()
        self.second_teacher_user = User(username="******")
        self.second_teacher_user.save()

        self.student = Student(user=self.user)
        self.student.save()
        self.second_student = Student(user=self.second_user)
        self.second_student.save()
        self.teacher = Professor(user=self.teacher_user)
        self.teacher.save()
        self.second_teacher = Professor(user=self.second_teacher_user)
        self.second_teacher.save()

        self.stage = Stage(id=1, name="Stage1", level=1)
        self.stage.save()
        self.second_stage = Stage(id=2, name="Stage2", level=1)
        self.second_stage.save()

        self.lesson = Lesson(id=1, name="English", stage_id=1)
        self.lesson.save()
        self.lesson.students.add(self.student)
        self.lesson.students.add(self.second_student)
        self.lesson.professors.add(self.teacher)
        self.lesson.save()

        self.second_lesson = Lesson(id=2, name="French", stage_id=2)
        self.second_lesson.save()
        self.second_lesson.students.add(self.second_student)
        self.second_lesson.professors.add(self.teacher)
        self.second_lesson.save()

        self.thread = Thread(title="Help",
                             author=self.user,
                             recipient=self.teacher_user)
        self.thread.save()

        self.second_thread = Thread(title="Send help",
                                    author=self.second_user,
                                    lesson=self.second_lesson)
        self.second_thread.save()

        self.third_thread = Thread(title="Information regarding w/e",
                                   author=self.teacher_user,
                                   professor=self.teacher)
        self.third_thread.save()

        self.fourth_thread = Thread(title="Information regarding spam",
                                    author=self.teacher_user,
                                    professor=self.teacher)
        self.fourth_thread.save()
예제 #2
0
    def setUp(self):
        self.user = User(username="******")
        self.user.set_password('12345')
        self.user.save()
        self.teacher_user = User(username="******")
        self.teacher_user.set_password('12345')
        self.teacher_user.save()

        self.student = Student(user=self.user)
        self.student.save()
        self.teacher = Professor(user=self.teacher_user)
        self.teacher.save()

        res1_content = {"title": "Res1"}
        self.res1 = Resource(added_by=self.teacher_user, content=res1_content)
        self.res1.save()

        self.section = Section(id=1, name="Section1")
        self.section.save()
        self.section.resource.add(self.res1)
        self.section.save()

        self.skill2 = Skill(id=2, name="Skill2", code="2")
        self.skill2.save()

        res2_content = {"title": "Res2"}
        self.res2 = Resource(added_by=self.teacher_user, content=res2_content)
        self.res2.save()

        self.skill3 = Skill(id=3, name="Skill3", code="3")
        self.skill3.save()
        self.skill3.resource.add(self.res2)
        self.skill3.save()

        self.skill4 = Skill(id=4, name="Skill4", code="4")
        self.skill4.section = self.section
        self.skill4.save()

        self.stage = Stage(id=1, name="Stage1", level=1)
        self.stage.save()
        self.stage.skills.add(self.skill3)
        self.stage.skills.add(self.skill4)
        self.stage.save()

        self.lesson = Lesson(id=1, name="English", stage_id=1)
        self.lesson.save()
        self.lesson.students.add(self.student)
        self.lesson.professors.add(self.teacher)
        self.lesson.save()

        self.s1 = Client()
        self.s1.login(username=self.user.username, password='******')

        self.t1 = Client()
        self.t1.login(username=self.teacher_user.username, password='******')
예제 #3
0
def create_professor():
    user = create_appuser()

    professor = Professor(
        app_user=user,
        number=random.randrange(1, 10000000000),
        rank=random.choice([
            "assist", "assistinv", "full", "fullvis", "associ", "associnv",
            "assocagr"
        ]),
    )

    professor.save()
예제 #4
0
    def test_public_professor_thread(self):
        user = User(username="******")
        user.save()

        professor_user = User(username="******")
        professor_user.save()
        professor = Professor(user=professor_user)
        professor.save()

        thread = Thread(title="Help", author=user, professor=professor)
        thread.clean()
        thread.save()

        self.assertTrue(thread.is_public_professor())
        self.assertFalse(thread.is_private())
        self.assertFalse(thread.is_public_lesson())
예제 #5
0
    def test_invalid_thread_both_recipient_professor(self):
        user = User(username="******")
        user.save()

        recipient = User(username="******")
        recipient.save()

        professor_user = User(username="******")
        professor_user.save()
        professor = Professor(user=professor_user)
        professor.save()

        thread = Thread(title="Help",
                        author=user,
                        recipient=recipient,
                        professor=professor)

        with self.assertRaises(ValidationError):
            thread.clean()
예제 #6
0
 def setUp(self):
     self.first_user = User(username="******")
     self.first_user.set_password('12345')
     self.first_user.save()
     self.second_user = User(username="******")
     self.second_user.set_password('12345')
     self.second_user.save()
     self.third_user = User(username="******")
     self.third_user.save()
     self.first_student = Student(user=self.first_user)
     self.first_student.save()
     self.second_student = Student(user=self.second_user)
     self.second_student.save()
     self.teacher = Professor(user=self.third_user)
     self.teacher.save()
     self.stage = Stage(id=1, name="Stage1", level=1)
     self.stage.save()
     self.lesson = Lesson(id=1, name="Lesson 1", stage_id=1)
     self.lesson.save()
     self.thread_lesson = Thread.objects.create(author=self.first_user,
                                                lesson=self.lesson,
                                                title="Thread 1",
                                                id=1)
     self.thread_lesson.save()
     self.thread_id = self.thread_lesson.id
     self.message = Message.objects.create(
         author=self.first_user,
         content="Content of message",
         thread=self.thread_lesson,
         created_date=utc.localize(datetime.now()),
         modified_date=utc.localize(datetime.now()))
     self.message.save()
     self.c = Client()
     self.c.login(username='******', password='******')
     self.c2 = Client()
     self.c2.login(username='******', password='******')
     self.file = SimpleUploadedFile('file.txt', b'OOOOOOOOOOOOOOOOOOOO')
     self.attachment = MessageAttachment.objects.create(
         name=self.file.name, file=self.file, message=self.message)
     self.attachment.save()
예제 #7
0
 def setUp(self):
     self.user1 = User(username='******')
     self.user1.set_password('12345')
     self.user1.save()
     self.teacher = Professor(user=self.user1)
     self.teacher.save()
     self.user2 = User(username="******")
     self.user2.save()
     self.student = Student(user=self.user2)
     self.student.save()
     self.stage = Stage(id=1, name="Stage1", level=1)
     self.stage.save()
     self.lesson = Lesson(id=1, name="Lesson 1", stage_id=1)
     self.lesson.save()
     self.skill1 = Skill(code=422230,
                         name="Compter deux par deux",
                         description="")
     self.skill1.save()
     self.skill2 = Skill(code=422231,
                         name="Lacer ses chaussures",
                         description="")
     self.skill2.save()
     self.c = Client()
     self.c.login(username='******', password='******')
예제 #8
0
    def setUp(self):
        self.user = User(username="******")
        self.user.set_password('12345')
        self.user.save()
        self.second_user = User(username="******")
        self.second_user.set_password('12345')
        self.second_user.save()
        self.teacher_user = User(username="******")
        self.teacher_user.save()
        self.second_teacher_user = User(username="******")
        self.second_teacher_user.save()

        self.student = Student(user=self.user)
        self.student.save()
        self.second_student = Student(user=self.second_user)
        self.second_student.save()
        self.teacher = Professor(user=self.teacher_user)
        self.teacher.save()
        self.second_teacher = Professor(user=self.second_teacher_user)
        self.second_teacher.save()

        self.skill1 = Skill(id=1, name="Skill1", code="1")
        self.skill1.save()

        self.skill2 = Skill(id=2, name="Skill2", code="2")
        self.skill2.save()

        self.section = Section(id=1, name="Section1")
        self.section.save()

        self.skill3 = Skill(id=3, name="Skill3", code="3")
        self.skill3.section = self.section
        self.skill3.save()

        self.skill4 = Skill(id=4, name="Skill4", code="4")
        self.skill4.section = self.section
        self.skill4.save()

        self.stage = Stage(id=1, name="Stage1", level=1)
        self.stage.save()
        self.stage.skills.add(self.skill1)
        self.stage.skills.add(self.skill2)
        self.stage.save()

        self.second_stage = Stage(id=2, name="Stage2", level=1)
        self.second_stage.save()
        self.second_stage.skills.add(self.skill3)
        self.second_stage.skills.add(self.skill4)
        self.second_stage.save()

        self.lesson = Lesson(id=1, name="English", stage_id=1)
        self.lesson.save()
        self.lesson.students.add(self.student)
        self.lesson.students.add(self.second_student)
        self.lesson.professors.add(self.teacher)
        self.lesson.save()

        self.second_lesson = Lesson(id=2, name="French", stage_id=2)
        self.second_lesson.save()
        self.second_lesson.students.add(self.second_student)
        self.second_lesson.professors.add(self.teacher)
        self.second_lesson.save()

        self.thread = Thread(title="Help",
                             author=self.user,
                             recipient=self.teacher_user)
        self.thread.save()

        self.second_thread = Thread(title="Send help",
                                    author=self.second_user,
                                    lesson=self.second_lesson)
        self.second_thread.save()

        self.third_thread = Thread(title="Information regarding w/e",
                                   author=self.teacher_user,
                                   professor=self.teacher)
        self.third_thread.save()

        self.fourth_thread = Thread(title="Information regarding spam",
                                    author=self.teacher_user,
                                    professor=self.teacher)
        self.fourth_thread.save()

        self.c1 = Client()
        self.c1.login(username=self.user.username, password='******')

        self.c2 = Client()
        self.c2.login(username=self.second_user.username, password='******')