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

Create /math/cube resource #17

Open
neumannrf opened this issue Mar 15, 2019 · 0 comments
Open

Create /math/cube resource #17

neumannrf opened this issue Mar 15, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@neumannrf
Copy link
Collaborator

As a user
I need to cube each element in the list
So that so that calculations can be automated.

Assumptions:

  • There should be a main.py file with the following content.
@math_ns.route('/cube')
@math_ns.doc(description='Takes the cube of the list.')
class CubeList(Resource):
    def put(self):
        return ms.cube_list(my_list)
  • The main.py file should include an external file above the from src import basic_services as bs line.
from src import math_services as ms
  • There should be a src/math_services.py file with the following content
def cube_list(integer_list):
    """
    Takes the cube of every integer in the list.

    Receives
    --------
    integer_list : list
        List of integer values.

    Returns
    -------
    cubed_list : list
        List of the cubes of integer values.
    """

    cubed_list = [x**3 for x in integer_list]
    integer_list.clear()
    integer_list.extend(cubed_list)
    return integer_list
  • There should be a test/math_test.py file with the following content.
from src import math_services as ms


def test_cube_list():
    assert ms.cube_list([]) == []
    assert ms.cube_list([1]) == [1]
    assert ms.cube_list([2]) == [8]
    assert ms.cube_list([1, 2]) == [1, 8]
    assert ms.cube_list([1, 2, 3]) == [1, 8, 27]

Acceptance criteria:

Given that the application stores a list of integers
When this resource is called
Then each integer number in the list is cubed.
@neumannrf neumannrf added the enhancement New feature or request label Mar 15, 2019
@renatomello renatomello self-assigned this Mar 27, 2019
@renatomello renatomello removed their assignment Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants