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

Create /basic/input resource #3

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

Create /basic/input resource #3

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 input a list of integers
So that it can be manipulated.

Assumptions:

  • There should be a main.py file with the following content below the /answer block.
@basic_ns.route('/input/<string:csv>')
@basic_ns.doc(params={'csv': 'Comma-separated integer values.'}, description='Inputs list.')
class InputList(Resource):
    def post(self, csv):
        my_list.clear()
        my_list.extend(bs.csv_to_list(csv))
        return my_list
  • The main.py file should include an external file above the from src import default_services as ds line.
from src import basic_services as bs
  • There should be a src/basic_services.py file with the following content
def csv_to_list(csv_string):
    """
    Converts a string with comma-separated integer values to a Python list of integers.

    Receives
    --------
    csv_string : string
        Comma-separated integer values (stored as strings).

    Returns
    -------
    integer_list : list
        List of integer values.
    """

    string_list = csv_string.split(',')
    integer_list = list(map(int, string_list))
    return integer_list
  • There should be a test/basic_test.py file with the following content.
from src import basic_services as bs


def test_csv_to_list():
    assert bs.csv_to_list('1') == [1]
    assert bs.csv_to_list('1,2') == [1, 2]
    assert bs.csv_to_list('1,2,3') == [1, 2, 3]

Acceptance criteria:

Given that integer lists should first be input before manipulated
When this resource is called
Then an integer list is input into the application.
@neumannrf neumannrf added the enhancement New feature or request label Mar 15, 2019
@neumannrf neumannrf self-assigned this Mar 21, 2019
@neumannrf neumannrf added this to the Sprint 0 milestone Mar 21, 2019
@neumannrf neumannrf mentioned this issue Mar 21, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant