def step(context, practice_uid, course_name, filename): course = Course.objects.get(name=course_name) practice = Practice.objects.get(uid=practice_uid, course=course) practiceFile = PracticeFile() practiceFile.name = filename practiceFile.file = "data/file.pdf" practiceFile.practice = practice practiceFile.save()
def step(context, practice_name, practice_file_id): practice_path = managepath.get_instance().get_practice_path() if not os.path.exists(practice_path): os.makedirs(name=practice_path) practice_filename = "practice_no_text_file.pdf" practice_filepath = os.path.join(practice_path, practice_filename) with open(practice_filepath, 'w') as test_file: lines = [ "first line\n", "second line\n", "third line\n", "fourth line\n", "fifth line\n" ] test_file.writelines(lines) practice = Practice.objects.filter(uid=practice_name)[0] practice_file = PracticeFile() practice_file.pk = practice_file_id practice_file.name = "Prueba" practice_file.file = practice_filepath practice_file.practice = practice practice_file.save()
def step(context, practice_name, practice_file_id): practice_path = managepath.get_instance().get_practice_path() if not os.path.exists(practice_path): os.makedirs(name=practice_path) practice_filename = "practice_no_text_file.pdf" practice_filepath = os.path.join(practice_path, practice_filename) with open(practice_filepath, 'w') as test_file: lines = ["first line\n", "second line\n", "third line\n", "fourth line\n", "fifth line\n"] test_file.writelines(lines) practice = Practice.objects.filter(uid=practice_name)[0] practice_file = PracticeFile() practice_file.pk = practice_file_id practice_file.name = "Prueba" practice_file.file = practice_filepath practice_file.practice = practice practice_file.save()