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

chore: enabling integration tests #355

Merged
merged 10 commits into from
Mar 26, 2024
Merged

Conversation

Anas12091101
Copy link

@Anas12091101 Anas12091101 commented Feb 9, 2024

What are the relevant tickets?

#354

What does this PR do?

This PR fixes integration tests and adds them to the GitHub CI workflow.

How should this be manually tested?

  • Check the CI run and verify that the tests run and pass.
For local testing:
  • Ensure your local edx-sga repo is in the src folder in the edx workspace.
  • Delete the pytest.ini file using rm ./pytest.ini.
  • Copy the setup.cfg file from edx-platform using cp /edx/app/edxapp/edx-platform/setup.cfg ..
  • Run tests using pytest ./edx_sga/tests/integration_tests.py.
  • Verify that all tests pass.

@Anas12091101 Anas12091101 force-pushed the fix-integration-tests branch 16 times, most recently from 4310b9d to 7d7da18 Compare February 15, 2024 18:13
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.40%. Comparing base (5f18e95) to head (7e48031).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
+ Coverage   53.75%   61.40%   +7.65%     
==========================================
  Files          16       16              
  Lines        1680     1705      +25     
  Branches      115      115              
==========================================
+ Hits          903     1047     +144     
+ Misses        764      642     -122     
- Partials       13       16       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Anas12091101 Anas12091101 force-pushed the fix-integration-tests branch 3 times, most recently from faeb281 to 35f4609 Compare February 15, 2024 20:00
@arslanashraf7
Copy link

@Anas12091101 We need to add codecov.yaml file for the coverage configurations checks that are failing above. A reference of that can be seen in our rapid response xBlock here. We can configure codecov w.r.t comments, coverage checks and behaviour. More details on codecov.yaml can be seen here.

@Anas12091101
Copy link
Author

Anas12091101 commented Feb 16, 2024

@Anas12091101 We need to add codecov.yaml file for the coverage configurations checks that are failing above.

@arslanashraf7 thanks for your comment. I think we don't need to add codecov.yml file here. The coverage was failing before because codecov was not covering the integration tests. Now all the checks are passing and the PR is ready for review

@arslanashraf7
Copy link

@Anas12091101 We need to add codecov.yaml file for the coverage configurations checks that are failing above.

@arslanashraf7 thanks for your comment. I think we don't need to add codecov.yml file here. The coverage was failing before because codecov was not covering the integration tests. Now all the checks are passing and the PR is ready for review

wow, That increased the coverage to the passing limit. But whenever we need to make changes in how codecov is configured we will need to add it. But thanks for letting me know. I'll take a look at the PR.

@arslanashraf7 arslanashraf7 self-assigned this Feb 20, 2024
@arslanashraf7
Copy link

@Anas12091101 Could you rebase this PR?

@Anas12091101 Anas12091101 force-pushed the fix-integration-tests branch 3 times, most recently from 5690a6d to 5e8c757 Compare February 27, 2024 10:51
- name: Run Integration Tests
run: |
cd ..
git clone https://github.com/openedx/devstack
Copy link
Author

@Anas12091101 Anas12091101 Feb 27, 2024

Choose a reason for hiding this comment

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

I was getting an error in the CI on make dev.clone.https command: make: *** No rule to make target 'dev.clone.https'. Stop.

I also reproduced the error locally. The command works fine in the openedx/devstack repository.

I replaced https://github.com/edx/devstack with https://github.com/openedx/devstack.

Copy link
Author

Choose a reason for hiding this comment

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

I tried to test this in the rapid response repo which is also using https://github.com/edx/devstack repository. The test PR throws the same error in the CI run.

Choose a reason for hiding this comment

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

Thanks for making this change.

Copy link

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

Just one last question, the rest is looking great.

self.personalize(block, **student)
user = student["module"].student
student_id = anonymous_id_for_user(user,self.course_id)
with mock.patch.object(StaffGradedAssignmentXBlock.get_submission,"__defaults__",(student_id,)):

Choose a reason for hiding this comment

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

Can you tell me more about why we needed this mocking? What made the existing tests break, were they not getting the StaffGradedAssignmentXBlock object now or was there some other reason?

Copy link
Author

@Anas12091101 Anas12091101 Mar 1, 2024

Choose a reason for hiding this comment

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

I was getting no submission object when the test was running. When I dig into it, I found that our SGA xblock is created with the staff user name in the make_one fn and our submission is being made with the student_id. The test is using block.student_view() which is calling self.student_state() -> self.get_submission() -> self.get_student_item_dict(student_id is None). By default the student_id is None and hence the xblock sets the student_id to the staff_id here. Therefore I mocked the get_submission method to use the student_id of the student, by which we have created the submission and not the staff id.

Choose a reason for hiding this comment

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

Alright, So, wouldn't it make sense to create both the SGA block and the submission with Student ID when we are testing it with a student? We might probably achieve this by adding an extra param in make_one method it uses the staff username as default when the username isn't passed to the function, otherwise use the username passed?

- name: Run Integration Tests
run: |
cd ..
git clone https://github.com/openedx/devstack

Choose a reason for hiding this comment

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

Thanks for making this change.

@arslanashraf7
Copy link

@Anas12091101 I've re-run tests on this PR to check if a new xBlock package is available and if that fixes the issue now.

Copy link

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

👍 Thanks for the patience on this. Don't forget to squash & merge.

@Anas12091101 Anas12091101 merged commit c9ba9c1 into master Mar 26, 2024
4 checks passed
@odlbot odlbot mentioned this pull request Mar 28, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants