Skip to content

Refactor stub implementation of LTI Provider. BLD-601. - #2029

Merged
olmar merged 1 commit into
masterfrom
oleg/lti_stub_refactor
Feb 11, 2014
Merged

Refactor stub implementation of LTI Provider. BLD-601. #2029
olmar merged 1 commit into
masterfrom
oleg/lti_stub_refactor

Conversation

@olmar

@olmar olmar commented Dec 23, 2013

Copy link
Copy Markdown
Contributor

Refactor stub implementation of LTI Provider.

Issue: https://edx-wiki.atlassian.net/browse/BLD-601.

@auraz please review.
@wedaly please review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't commit commented-out code to the repository.

@olmar

olmar commented Dec 30, 2013

Copy link
Copy Markdown
Contributor Author

@wedaly I`m looking for how it possible to launch such stubs manually. Do you know smth about it?

Comment thread common/djangoapps/terrain/stubs/lti.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The superclass defines a send_response method that accepts a headers kwarg. You should use that to send the headers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@wedaly

wedaly commented Jan 9, 2014

Copy link
Copy Markdown
Contributor
  1. Take another look at the StubHttpService base class -- you can re-use the helper methods defined there instead of re-implementing them in the subclass.

  2. I don't understand why the stub needs different configuration for unit/acceptance/manual testing. For unit tests, you should use mock.patch to mock requests.post. I don't understand why manual testing is handled as a separate case.

  3. Please check for pylint/pep8 style violations.

  4. Rebase onto master and resolve merge conflicts.

Please let me know when you're ready for me to take another look.

@wedaly

wedaly commented Jan 9, 2014

Copy link
Copy Markdown
Contributor

In terms of starting the server manually, you can add a short Python script that starts the server on a particular port. I'd recommend adding this directly in common/djangoapps/terrain/stubs/lti.py for now. It should look something like this:

 if __name__ == "__main__":
     service = StubLtiService()
     service.start()
     try:
          while true:
               pass
     except KeyboardInterrupt:
          service.shutdown()
          exit(0)

@wedaly

wedaly commented Jan 10, 2014

Copy link
Copy Markdown
Contributor

It looks like the LTI module is setting the hostname for the callback URL here:

https://github.com/edx/edx-platform/blob/master/common/lib/xmodule/xmodule/lti_module.py#L284-L299

It's setting it based on the XBlock's self.system.hostname property. This, in turn, looks like it's configured using Django settings:

https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/module_render.py#L391

We have SITE_NAME set to localhost in the sandbox, so it should be safe to change it to localhost in dev and devstack settings as well. I'd prefer to configure this in settings rather than within the stub server.

@olmar

olmar commented Feb 3, 2014

Copy link
Copy Markdown
Contributor Author

@wedaly please continue review.

Comment thread common/djangoapps/terrain/stubs/lti.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a private method; if so, it should have an underscore in front to denote that:

_create_content

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

made method to be private

@wedaly

wedaly commented Feb 3, 2014

Copy link
Copy Markdown
Contributor

I made some style comments, and I'm still unsure about explicitly setting http/https for the test environment. You'll also need to rebase and fix merge conflicts.

Please let me know when you're ready for another round of review.

@olmar

olmar commented Feb 4, 2014

Copy link
Copy Markdown
Contributor Author

@auraz this PR involves some changes to LTI Module also. Please review.

@olmar

olmar commented Feb 4, 2014

Copy link
Copy Markdown
Contributor Author

@wedaly please continue review.

@wedaly

wedaly commented Feb 4, 2014

Copy link
Copy Markdown
Contributor

👍 but please squash your commits before merging.

Comment thread common/djangoapps/terrain/stubs/lti.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a) add comment why we do this
b) please remove changes to quoting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants