def test_update(self):
        Course.create_one(**course_data[1])
        db.session.commit()

        Course.get_one(code=course_data[1]['code']).update(
            description='Updated description.')
        db.session.commit()

        assert Course.get_one(
            code=course_data[1]['code']).description == 'Updated description.'
    def test_delete_course(self):
        resp = self.client.delete(f'/courses/{self.courses[0].guid}')
        assert resp.status_code == 204

        assert Course.get_one(guid=self.courses[0].guid) is None

        assert self.client_not_logged_in.delete(f'/courses/{self.courses[0].guid}').status_code == 403
Exemple #3
0
def delete(guid):
    course = Course.get_one(guid=guid)
    if not course:
        raise EntryDoesNotExist

    course.delete()
    db.session.commit()
Exemple #4
0
def update(guid, data):
    course = Course.get_one(guid=guid)
    if not course:
        raise EntryDoesNotExist

    course.update(**data)
    db.session.commit()

    return course
    def test_add(self):
        course = Course.create_one(**course_data[0])
        db.session.commit()

        course = Course.get_one(guid=course.guid)
        assert course is not None
        assert course.code == course_data[0]['code']
        assert course.title == course_data[0]['title']
        assert course.description == course_data[0]['description']
        assert course.takeaways == course_data[0]['takeaways']
        assert course.tags == course_data[0]['tags']
        assert course.outlines == course_data[0]['outlines']
    def test_delete(self):
        Course.get_one(code=course_data[0]['code']).delete()
        db.session.commit()

        assert Course.get_one(code=course_data[0]['code']) is None
Exemple #7
0
def get(guid):
    obj = Course.get_one(guid=guid)
    if not obj:
        raise EntryDoesNotExist

    return obj