Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Brenda Patel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Chansa Kabwe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Claudio Mirti.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Emily R. Wright.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Jasmine Latham.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/John Goodloe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Linda Obregon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Maria Eduarda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Sebastian Bello.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testimonials/fixtures/avatars/Stephen Okiya.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
256 changes: 256 additions & 0 deletions testimonials/migrations/0005_load_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
# Generated by Django 4.2.13 on 2024-06-25 15:30

import logging
from pathlib import Path

from django.core.files import File
from django.db import migrations

"""
Fix an issue with PIL's logger when running in test
https://github.com/camptocamp/pytest-odoo/issues/15
"""
pil_logger = logging.getLogger("PIL")
pil_logger.setLevel(logging.INFO)

fixtures = [
{
"attestant_name": "Maria Eduarda",
"title": "Independent Learner, Brazil",
"quote": (
"I am not exaggerating when I say MIT OpenCourseWare "
"has changed my life significantly for the better… "
"I would never have had the opportunity to "
"take Calculus during high school, let alone Solid State Chemistry. "
"These courses have greatly expanded my "
"interests and opportunities and I'm forever grateful for that."
),
"position": 1,
"offerors": ["ocw"],
},
{
"attestant_name": "Chansa Kabwe",
"title": "Independent Learner, Zambia",
"quote": (
"OpenCourseWare continues to be a big part of my career."
" My foundation is linked to it — I don't know if "
"I would be the same engineer today if not for OpenCourseWare."
),
"position": 1,
"offerors": ["ocw"],
},
{
"attestant_name": "Emmanuel Kasigazi",
"title": "Entrepreneur, Uganda",
"quote": (
"This is what OpenCourseWare has enabled me to do: "
"I get the chance to not only watch the "
"future happen, but I can actually be a part of it and create it."
),
"position": 1,
"offerors": ["ocw"],
},
{
"attestant_name": "Arthur Julio Nelson",
"title": "Brand Strategy Lead, Google",
"quote": (
"The Bootcamp is, well, it's an accelerator "
"meets a creativity incubator. "
"It's all of these things mashed into one. "
"If you come into the Bootcamp with a "
"purpose and desire for impact and where you want "
"to channel it, the Bootcamp will help you unleash it."
),
"position": 1,
"offerors": ["bootcamps"],
},
{
"attestant_name": "Jasmine Latham",
"title": "Lead Data Scientist, Office for National Statistics",
"quote": (
"I am very pleased with the course content, "
"it is exactly the level I am looking for. "
"Each professor/course presenter has packed "
"a lot of information and has explained complex "
"algorithms in good detail. "
"Some with good sense of humor. Thank you very much."
),
"position": 1,
"offerors": ["xpro"],
},
{
"attestant_name": "Lauren Moscioni",
"title": "Associate, Morgan Stanley",
"quote": (
"Coming from the finance sector, "
"I wanted to learn more about real estate as an "
"alternative investment for ultra-high-net-worth clients. "
"What I got from MIT was a well-rounded, "
"holistic view of the state of the field."
),
"position": 1,
"offerors": ["mitpe"],
},
{
"attestant_name": "Sebastian Bello",
"title": "MicroMasters learner",
"quote": (
"I did the Micromaster in supply chain, "
"what motivated me the most to finish it was "
"to have a certificate in supply chain "
"from MIT to improve my career. I was so engaged with "
"the courses that I wanted to continue learning, "
"now I'm doing the Supply Chain Management Master's at MIT."
),
"position": 1,
"offerors": ["mitx"],
},
{
"attestant_name": "John Goodloe",
"title": (
"Senior Director for Society Business Solutions, "
"American Chemical Society (ACS)"
),
"quote": (
"The courses at MIT Sloan Executive Education brought together "
"true leaders from across the world. You're in classes with diplomats, "
"CEOs, heads of family businesses and "
"Fortune 500s—every course is a different mix."
),
"position": 1,
"offerors": ["see"],
},
{
"attestant_name": "Linda Obregon",
"title": "Founder and CEO",
"quote": (
"The program experience was 10-fold compared to what I expected. "
"They not only taught me how to create "
"a company in a week, but they gave me a "
"supportive network of the best "
"and brightest minds. After I left the Bootcamp, "
"I founded a startup that uses science and"
" plants to develop high-protein and tasty new foods."
),
"position": 1,
"offerors": ["bootcamps"],
},
{
"attestant_name": "Murali Thyagarajan",
"title": "DBA & Application Support, NASDAQ",
"quote": (
"The course was easy to understand and had depth. "
"All the concepts were clearly laid out and explained. "
"This is the best course I have come across on this topic."
),
"position": 2,
"offerors": ["xpro"],
},
{
"attestant_name": "Claudio Mirti",
"title": "Senior Advanced Analytics and AI Specialist, Microsoft",
"quote": (
"The Certificate Program in Machine Learning and AI is a great experience. "
"You get a lot of powerful insights during "
"exchanges with the professors and other "
"students—and you learn how to incorporate the "
"material into your daily work."
),
"position": 2,
"offerors": ["mitpe"],
},
{
"attestant_name": "Stephen Okiya",
"title": "MITx Learner",
"quote": (
"I am really grateful for the efforts by MIT in coming up with innovative "
"ways of making quality education affordable "
"and accessible to everyone all over the world. "
"I am sure that the programs impact the lives of millions of "
"people either directly or indirectly "
"hence making the world a better place."
),
"position": 2,
"offerors": ["mitx"],
},
{
"attestant_name": "Brenda Patel",
"title": "CEO, Bonova Advisory",
"quote": (
"You're a part of an ecosystem that is a life-long community of "
"people with the same goal to create something new and valuable. "
"It's an investment of five days, but it stays with you forever."
),
"position": 2,
"offerors": ["see"],
},
{
"attestant_name": "Emily R. Wright",
"title": "Versatile Technologist",
"quote": (
"This is an awesome program for emerging leaders "
"and for those currently in leadership positions. "
"The knowledge, tools, and techniques "
"are very useful to companies worldwide. "
"I would highly recommend this program to all levels of employees."
),
"position": 3,
"offerors": ["xpro"],
},
{
"attestant_name": "Anesha Santhanam",
"title": "MITx Learner",
"quote": (
"I recently completed an MITx course in Python, "
"and it was phenomenal. I looked into this course to "
"give me a better foundation and a deeper "
"understanding so I could use Python "
"in other settings and applications. "
"I'm using what I learned everyday to further my passion, "
"so thank you for providing me with this opportunity!"
),
"position": 3,
"offerors": ["mitx"],
},
]


def load_fixtures(apps, schema_editor):
"""
Load fixtures for testimonials
"""
Attestation = apps.get_model("testimonials", "Attestation")
LearningResourceOfferor = apps.get_model(
"learning_resources", "LearningResourceOfferor"
)

for fixture in fixtures:
offerors = fixture.pop("offerors")
testimonial, _ = Attestation.objects.get_or_create(
attestant_name=fixture["attestant_name"],
title=fixture["title"],
defaults=fixture,
)
# make sure related offerors exists in system before setting
if LearningResourceOfferor.objects.filter(pk__in=offerors).count() == len(
offerors
):
testimonial.offerors.set(offerors)
if not testimonial.avatar:
"""
Save the image from fixture so alternate sizes are generated
"""
with Path.open(
f"testimonials/fixtures/avatars/{fixture["attestant_name"]}.png", "rb"
) as imagefile:
testimonial.avatar.save("avatar.png", File(imagefile), save=True)


class Migration(migrations.Migration):
dependencies = [
("testimonials", "0004_update_attestation_avatar_make_optional"),
]

operations = [
migrations.RunPython(load_fixtures, migrations.RunPython.noop),
]
5 changes: 4 additions & 1 deletion testimonials/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def test_attestation_list(client):
"""Test that attestations can be listed"""

Attestation.objects.all().delete()
attestation_batch = sorted(AttestationFactory.create_batch(5), key=lambda a: a.id)

list_url = reverse("testimonials:v0:testimonials_api-list")
Expand Down Expand Up @@ -49,6 +49,7 @@ def test_attestation_filters(
last attestation; otherwise, it'll be for the channel and the offeror
added to the 4th attestation.
"""
Attestation.objects.all().delete()

attestation_batch = sorted(AttestationFactory.create_batch(6), key=lambda a: a.id)
api_params = {}
Expand Down Expand Up @@ -108,6 +109,7 @@ def test_attestation_filters(

def test_attestation_published(client):
"""Test that just published attestations are listed"""
Attestation.objects.all().delete()

attestation_batch = sorted(AttestationFactory.create_batch(4), key=lambda a: a.id)

Expand Down Expand Up @@ -151,6 +153,7 @@ def test_attestation_order(client):
- In the case where more than one row has the same position, they should be
displayed in order of `updated_on` for that position.
"""
Attestation.objects.all().delete()

attestation_batch = [AttestationFactory.create(position=i) for i in range(1, 6)]

Expand Down