def test_action_object_creation_errors(db, course_strange, assignment_tree, user_johaannes): role = "instructor" release_file = "/some/random/path/to/a/file.tzg" orm_subscription = Subscription(user_id=user_johaannes.id, course_id=course_strange.id, role=role) db.add(orm_subscription) db.commit() action = Action( user_id=user_johaannes.id, assignment_id=assignment_tree.id, location=release_file, ) db.add(action) with pytest.raises(IntegrityError): db.commit() db.rollback() # #### Why won't you work in github Actions, you bar steward # action = Action( # user_id=user_johaannes.id, # assignment_id=assignment_tree.id, # location="/some/random/path/to/a/file.tzg", # action="foo", # ) # db.add(action) # with pytest.raises(Exception): # db.commit() # db.rollback() orm_action = Action( action=AssignmentActions.released, location="/some/random/path/to/a/file.tzg", ) # # Why does that work?? db.add(orm_action) db.commit() orm_action.user_id = user_johaannes.id orm_action.assignment_id = assignment_tree.id db.commit()
def test_all_the_unicode(db, assignment_a2ovi, user_rur, course_strange): # subscribe user to course # add assignment to course role = "instructor" release_file = "/some/random/path/to/a/file.tzg" orm_subscription = Subscription(user_id=user_rur.id, course_id=course_strange.id, role=role) db.add(orm_subscription) assignment_a2ovi.course_id = course_strange.id db.commit() found_by_pk = Subscription.find_by_pk(db, orm_subscription.id) assert found_by_pk.id == orm_subscription.id assert orm_subscription.course.course_title == "Damnation Alley" # release orm_action = Action( action=AssignmentActions.released, location=release_file, ) db.add(orm_action) db.commit() orm_action.user_id = user_rur.id orm_action.assignment_id = assignment_a2ovi.id db.commit() # fetch orm_action = Action( user_id=user_rur.id, assignment_id=assignment_a2ovi.id, action=AssignmentActions.fetched, location=release_file, ) db.add(orm_action) db.commit() found = Action.find_most_recent_action(db, assignment_a2ovi.id) assert found.user.name == user_rur.name