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

Add regression testing for channel update deletion behaviour #11896

Merged

Conversation

thesujai
Copy link
Contributor

@thesujai thesujai commented Feb 17, 2024

Summary

Add test cases as mentioned in #5960 (comment)
Also handle the case when current_version or current_partial is None, preventing the TypeError from occurring.

References

Fixes #5960

Reviewer guidance

I am not sure about my test_full_import_with_newer_version which apparently is failing


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: small labels Feb 17, 2024
@thesujai thesujai changed the title Test channel update deletion Add regression testing for channel update deletion behaviour Feb 17, 2024
@MisRob MisRob requested review from rtibbles and ozer550 February 19, 2024 08:49
@thesujai
Copy link
Contributor Author

@rtibbles
for test_full_import_with_newer_version i am getting following error:

def raise_(
    exception, with_traceback=None, replace_context=None, from_=False
):
    r"""implement "raise" with cause support.

        :param exception: exception to raise
        :param with_traceback: will call exception.with_traceback()
        :param replace_context: an as-yet-unsupported feature.  This is
         an exception object which we are "replacing", e.g., it's our
         "cause" but we don't want it printed.    Basically just what
         ``__suppress_context__`` does but we don't want to suppress
         the enclosing context, if any.  So for now we make it the
         cause.
        :param from\_: the cause.  this actually sets the cause and doesn't
         hope to hide it someday.

        """
    if with_traceback is not None:
        exception = exception.with_traceback(with_traceback)

    if from_ is not False:
        exception.__cause__ = from_
    elif replace_context is not None:
        # no good solution here, we would like to have the exception
        # have only the context of replace_context.__context__ so that the
        # intermediary exception does not change, but we can't figure
        # that out.
        exception.__cause__ = replace_context

    try:
       raise exception

E sqlalchemy.exc.ArgumentError: SQL expression for WHERE/HAVING role expected, got .

../../../.pyenv/versions/3.9.9/envs/kolibriNew/lib/python3.9/site-packages/sqlalchemy/util/compat.py:211: ArgumentError
============================================ 1 failed, 4 passed in 16.73 seconds ============================================

@rtibbles
Copy link
Member

My first suggestion here would be to use the TransactionTestCase in the same way as the other test cases in this file. This is because we are using SQLAlchemy in the ChannelImport logic, but the regular TestCase doesn't play nicely with that.

It may be necessary to subclass the ContentImportBase class for this, to do additional setup and mocking: https://github.com/learningequality/kolibri/pull/11896/files#diff-192861a164181b5a5a8f25abf4bfa8502039d501ad331a5b24b7b149cb0d6f41R381

@thesujai
Copy link
Contributor Author

Thanks for the review!
I made the suggested changes, let me know if the tests are serving the purpose.

I also have a confusion that in this elif condition https://github.com/learningequality/kolibri/blob/develop/kolibri/core/content/utils/channel_import.py#L744 shouldn't we return a False?

@rtibbles
Copy link
Member

I also have a confusion that in this elif condition https://github.com/learningequality/kolibri/blob/develop/kolibri/core/content/utils/channel_import.py#L744 shouldn't we return a False?

No - in that elif condition we are deleting the currently imported channel metadata, so we need to return True. If we returned False, we would delete the existing metadata, and then not import the updated metadata.

@thesujai
Copy link
Contributor Author

Okay thanks

@rtibbles rtibbles self-assigned this Feb 27, 2024
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me, thank you!

@rtibbles
Copy link
Member

rtibbles commented Mar 2, 2024

Merging with the broken docs build, as this doesn't appear to be caused by this PR.

@rtibbles rtibbles merged commit caa49ad into learningequality:develop Mar 2, 2024
30 of 31 checks passed
@thesujai thesujai deleted the test_channel_update_deletion branch March 2, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add regression testing for channel update deletion behaviour
2 participants