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

Create /math/multiply resource #20

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

Create /math/multiply resource #20

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

Comments

@neumannrf
Copy link
Collaborator

As a user
I need to multiply each element in the list by an integer value
So that so that calculations can be automated.

Assumptions:

  • There should be a main.py file with the following content.
@math_ns.route('/multiply/<int:integer>')
@math_ns.doc(params={'integer': 'Integer value.'}, description='Multiply list by an integer.')
class MultiplyList(Resource):
    def put(self, integer):
        return ms.multiply_list(my_list, integer)
  • 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 multiply_list(integer_list, integer_value):
    """
    Multiply every integer in the list by an integer value.

    Receives
    --------
    integer_list : list
        List of integers.

    integer_value : integer
        Integer value by which every element should be multiplied.

    Returns
    -------
    multiplied_list : list
        List of integers multiplied by input value.
    """

    multiplied_list = [integer_value*x for x in integer_list]
    integer_list.clear()
    integer_list.extend(multiplied_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_multiply_list():
    assert ms.multiply_list([], 1) == []
    assert ms.multiply_list([1], 0) == [0]
    assert ms.multiply_list([1], 1) == [1]
    assert ms.multiply_list([1], 2) == [2]
    assert ms.multiply_list([1, 2], 0) == [0, 0]
    assert ms.multiply_list([1, 2], 1) == [1, 2]
    assert ms.multiply_list([1, 2], 2) == [2, 4]
    assert ms.multiply_list([1, 2, 3], 0) == [0, 0, 0]
    assert ms.multiply_list([1, 2, 3], 1) == [1, 2, 3]
    assert ms.multiply_list([1, 2, 3], 2) == [2, 4, 6]

Acceptance criteria:

Given that the application stores a list of integers
When this resource is called
Then each number in the list is multiplied by an integer value.
@neumannrf neumannrf added the enhancement New feature or request label Mar 15, 2019
@Qebuqci Qebuqci self-assigned this Mar 21, 2019
@Qebuqci Qebuqci added this to the Sprint 1 milestone Mar 21, 2019
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

Successfully merging a pull request may close this issue.

2 participants