Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flaky test: test_serialize_learning_resource_for_bulk #1070

Open
shanbady opened this issue Jun 12, 2024 · 0 comments
Open

flaky test: test_serialize_learning_resource_for_bulk #1070

shanbady opened this issue Jun 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@shanbady
Copy link
Contributor

Expected Behavior

Test should always pass

Current Behavior

Test fails intermittentlyl. failure log https://github.com/mitodl/mit-open/actions/runs/9487430224/job/26144060434?pr=1063#step:11:163

resource_type = 'program', is_professional = True, no_price = True

    @pytest.mark.django_db()
    @pytest.mark.parametrize(
        "resource_type",
        set(LearningResourceType.names()) - {LearningResourceType.course.name},
    )
    @pytest.mark.parametrize("is_professional", [True, False])
    @pytest.mark.parametrize("no_price", [True, False])
    def test_serialize_learning_resource_for_bulk(resource_type, is_professional, no_price):
        """
        Test that serialize_program_for_bulk yields a valid LearningResourceSerializer for resource types other than "course"
        The "course" resource type is tested by `test_serialize_course_numbers_for_bulk` below.
        """
        resource = factories.LearningResourceFactory.create(
            resource_type=resource_type, professional=is_professional, runs=[]
        )
        LearningResourceRunFactory.create(
            learning_resource=resource, prices=[Decimal(0.00 if no_price else 1.00)]
        )
        free_dict = {
            "free": resource_type
            not in [LearningResourceType.program.name, LearningResourceType.course.name]
            or (no_price and not is_professional)
        }
>       assert serializers.serialize_learning_resource_for_bulk(resource) == {
            "_id": resource.id,
            "resource_relations": {"name": "resource"},
            "created_on": resource.created_on,
            **free_dict,
            **LearningResourceSerializer(resource).data,
        }
E       AssertionError: assert {'_id': 2868,...g 8852'], ...} == {'_id': 2868,...g 8852'], ...}
E         Omitting 30 identical items, use -vv to show
E         Differing items:
E         {'program': {'courses': [{'id': 2869, 'topics': [{'id': 8280, 'name': 'Topic 8281', 'parent': None, 'channel_url': Non...d': True, 'languages': ['es'], 'url': 'https://lopez-martinez.org/', 'professional': False, 'next_start_date': None}]}} != {'program': {'courses': [{'id': 2869, 'topics': [{'id': 8280, 'name': 'Topic 8281', 'parent': None, 'channel_url': Non...d': True, 'languages': ['es'], 'url': 'https://lopez-martinez.org/', 'professional': False, 'next_start_date': None}]}}
E         Full diff:
E           {
E            '_id': 2868,
E            'certification': True,
E            'certification_type': {'code': 'professional',
E                                   'name': 'Professional Certificate'},
E            'course_feature': ['Tag 8849', 'Tag 8850', 'Tag 8851', 'Tag 8852'],
E            'created_on': datetime.datetime(2024, 6, 12, 18, 7, 13, 553775, tzinfo=datetime.timezone.utc),
E            'departments': [{'channel_url': None,
E                             'department_id': '2818',
E                             'name': '2818 name',
E                             'school': {'id': 2816,
E                                        'name': '2815 name',
E                                        'url': 'https://green.info/'}}],
E            'description': 'Could medical expect indicate kitchen.',
E            'free': False,
E            'full_description': 'Guess security her hard hear sing city cost. Left '
E                                'shoulder subject government. Billion everything movie no '
E                                'common race.',
E            'id': 2868,
E            'image': {'id': 6327, 'url': 'https://www.duarte-campbell.com/', 'description': 'Family throughout consumer deal scientist stage watch. Expert whose ready sound second prevent course.\nFilm face red. Our stay imagine play remain much shake.', 'alt': 'Standard majority responsibility rock responsibility low ground total. Reality away another role identify. Evening power professional today receive way.'},
E            'languages': ['es'],
E            'last_modified': '[199](https://github.com/mitodl/mit-open/actions/runs/9487430224/job/26144060434?pr=1063#step:11:200)7-11-22T15:34:39.043868Z',
E            'learning_format': [{'code': 'in_person', 'name': 'In person'}],
E            'learning_path_parents': [],
E            'next_start_date': None,
E            'offered_by': {'channel_url': None,
E                           'code': 'see',
E                           'name': 'Sloan Executive Education'},
E            'platform': {'code': 'globalalumni', 'name': 'Global Alumni'},
E            'prices': [Decimal('0.00')],
E            'professional': True,
@shanbady shanbady added the bug Something isn't working label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant