Пример #1
0
    def test_user_can_remove_photo(self):
        photo_path = StudentStorage.save(
            FileStorage(open(self.test_image_path)))

        student_org = {
            "name": "cool",
            "second_name": "second_name",
            "sex": 0,
            "photo": photo_path
        }

        s = Student.create(**student_org)

        self.assertTrue(os.path.exists(photo_path))

        data = {"remove_photo": True}

        response = self.client.post(url_for("university.student_update",
                                            student_id=s.id),
                                    data=data)
        self.assertRedirects(response, "/")
        db.session.refresh(s)
        self.assertIsNone(s.photo)
        self.assertFalse(os.path.exists(photo_path))
        self.assertEqual(s.name, student_org['name'])
        self.assertEqual(s.second_name, student_org['second_name'])
        self.assertEqual(s.sex, student_org['sex'])
Пример #2
0
    def setUp(self):
        super(TestMarksApi, self).setUp()

        self.lesson1 = Lesson.create()
        self.lesson2 = Lesson.create()

        self.student = Student.create()
        self.mark = Mark.create(lesson_id=self.lesson1.id,
                                student_id=self.student.id,
                                value=1)
Пример #3
0
    def setUp(self):
        super(TestGroupMarksView, self).setUp()
        self.group = Group.create(year=2014, title="2222")
        self.discipline_without_lessons = Discipline.create(title="d1")
        self.discipline_with_lesson = Discipline.create(title="d2")

        self.group = Group.create()
        self.student = Student.create(group_id=self.group.id)
        # self.lesson1 = Lesson.create(discipline_id=self.hidden_discipline.id)
        self.lesson2 = Lesson.create(
            group_id=self.group.id,
            discipline_id=self.discipline_with_lesson.id)
        # self.mark1 = Mark.create(lesson_id=self.lesson1.id, student_id=self.student.id)
        self.mark2 = Mark.create(lesson_id=self.lesson2.id,
                                 student_id=self.student.id)
Пример #4
0
    def test_user_can_update_student(self):
        s = Student.create(
            name="cool",
            second_name="second_name",
            sex=0,
        )

        data = {
            "name": "m",
            "second_name": "k",
            "sex": 1,
            "photo": open(self.test_image_path)
        }

        response = self.client.post(url_for("university.student_update",
                                            student_id=s.id),
                                    data=data)
        self.assertRedirects(response, "/")
        db.session.refresh(s)

        self.assertTrue(os.path.exists(s.photo))
        self.assertEqual(s.name, data['name'])
        self.assertEqual(s.second_name, data['second_name'])
        self.assertEqual(s.sex, data['sex'])
Пример #5
0
 def test_guest_cant_update_student(self):
     s = Student.create()
     return self.client.post(
         url_for("university.student_update", student_id=s.id))
Пример #6
0
 def test_set_file_field(self):
     student = Student()
     student.photo = "cool"
     db.session.add(student)
     db.session.commit()
Пример #7
0
 def test_set_file_field(self):
     student = Student()
     student.photo = "cool"
     db.session.add(student)
     db.session.commit()