def unmocked_course(mock_update_db): return Course( name="coursey course", link="https://udemy.com/coursey-course", description="the coursiest of courses", imageName="image.png", )
def load_test_data(): """Load test data into db.""" courses = [ course_with_coupons_and_quotes, course_without_coupons_and_quotes ] users = [admin_user] review_quotes = ["Wowza", "Stinks"] try: for course in courses: Course(**course) for user in users: User(**user) course = Course.query.first() for review_quote in review_quotes: ReviewQuote(body=review_quote, courseId=course.id) for coupon in coupons: Coupon(**coupon, courseId=course.id) for talk in talks: Talk(**talk) for tag in tags: Tag(tagName=tag) for cheat_sheet in cheat_sheets: CheatSheet(**cheat_sheet) # artifically backdate the regex cheat sheet to test updating the date cheat_sheet = CheatSheet.query.filter( CheatSheet.title == "Regex Cheat Sheet", ).one() cheat_sheet.updated_at = date(2020, 2, 2) db.session.add(cheat_sheet) db.session.commit() except (IntegrityError, UniqueViolation, SQLAlchemyError, InvalidRequestError) as e: # Keep from printing hundreds of lines simply for a db issue red = "\033[91m" print(f"{red}>>>>>>>>CORRUPT DATABASE<<<<<<<<<") print(f"{red}{e}")
def course_with_coupons(mock_update_db, iso_30_days_from_now): return Course( name="coursey course", link="https://udemy.com/coursey-course", description="the coursiest of courses", imageName="image.png", coupons=[ { "utcExpirationISO": iso_30_days_from_now, "link": "http://link?GOOD_COUPON", "price": 1.99, }, { "link": "http://link?BAD_COUPON", "utcExpirationISO": iso_30_days_from_now, "price": 1111.99, }, ], )
def test_to_dict(mock_update_db): review_quote = ReviewQuote( courseId=1, body="greatest course ever!!!!", ) course = Course(name="name", description="desc", link="link", imageName="imgname") review_quote.course = course quote_dict = review_quote.to_dict() assert set(quote_dict.keys()) == { "id", "courseId", "body", "courseName", "courseLink", }
def load_test_data(): """Load test data into db.""" courses = [ course_with_coupons_and_quotes, course_without_coupons_and_quotes ] users = [admin_user] review_quotes = ["Wowza", "Stinks"] for course in courses: Course(**course) for user in users: User(**user) course = Course.query.first() for review_quote in review_quotes: ReviewQuote(body=review_quote, courseId=course.id) for talk in talks: Talk(**talk)