Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
68 lines (56 loc) · 4.37 KB

3-EXPLORE.md

File metadata and controls

68 lines (56 loc) · 4.37 KB

Exploring the Python application

Cloning the repository

  1. Log in to GitHub.
  2. From the drop-down menu on the left, choose the neumannrf organization.
  3. Go to the agile-tutorial repository page.
  4. Click the green button Clone or download and copy the address git@github.com:neumannrf/agile-tutorial.git.
  5. Open Visual Studio Code and summon the Command Palette with
  6. Type clone and select Git: Clone from the list.
  7. Paste the git@github.com:neumannrf/agile-tutorial.git address and select the destination.
  8. Open the newly cloned repository.

Exploring the files

  1. The .github/ folder contains the templates used when a new issue or pull request is created.
  2. The docs/ folder contains the step-by-step instructions for the tutorial.
  3. The src/ folder contains the Python code for the API services.
  4. The test/ folder contains the Python code for the API tests.
  5. The .editorconfig file contains the standardisation of coding style.
  6. The .gitignore file contains the names of the files to be ignore by git.
  7. The .travis.yml file contains the build, test and deploy instructions for Travis CI.
  8. The LICENSE file contains the standard Apache-2.0 open-source license.
  9. The Procfile file contains the command required to launch the Cloud Foundry Application on IBM Cloud.
  10. The README.md file contains the welcome page and table of contents for the tutorial.
  11. The main.py file contains the Python code for the API resources.
  12. The manifest.yml file contains the definition of the Cloud Foundry Application on IBM Cloud.
  13. The requirements.txt file contains the list of Python dependencies.
  14. The runtime.txt file contains Python version to be used by the Cloud Foundry Application on IBM Cloud.

Testing the example implementation

  1. Open the http://agile-tutorial.mybluemix.net/ application in a browser.
  2. Click the default namespace to expose its API resources.
  3. Click the /answer API resources to expose its documentation.
  4. Click the Try it out button and then Execute.
  5. Confirm if the Response body contains the correct answer.

Understanding the API resources

  1. Open the agile-tutorial repository in Visual Studio Code.
  2. Open the main.py file.
  3. Read the code block associated with the /answer resource and compare it to the live application.
    • @api.route() defines the endpoint URL.
    • @api.doc() provides the documentation.
    • get() determines the HTTP method.
    • return calls an external service located in src/default_services.py.
  4. Note how an external file was included by from src import default_services as ds.

Understanding the API services

  1. Open the agile-tutorial repository in Visual Studio Code.
  2. Open the src/default_services.py file.
  3. Read the code block associated with the TheAnswerToLifeTheUniverseAndEverything() service and compare it to the live application.
    • TheAnswerToLifeTheUniverseAndEverything() is the function name evoked in the return statement of the /answer resource.
    • The documentation block explains the scope of the service and its input/output parameters.
    • return 42 determines the Response body in the live application.

Understanding the API tests

  1. Open the agile-tutorial repository in Visual Studio Code.
  2. Open the test/default_test.py file.
  3. Read the code block associated with the test_answer() test and compare it to the Travis CI build log.
    • from src import default_services as ds includes the external file containing the service to be tested.
    • assert determines what is the expect behaviour for that service.