lab-random-maksktl created by GitHub Classroom
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
github-classroom[bot] b5349e341f
Initial commit
2 years ago
taskManager Initial commit 2 years ago
tests Initial commit 2 years ago
.gitignore Initial commit 2 years ago
README.md Initial commit 2 years ago
openapi.json Initial commit 2 years ago
poetry.lock Initial commit 2 years ago
pyproject.toml Initial commit 2 years ago

README.md

Mutation Testing - Practical Assignment 1 (4pts)

Task Manager - Project

In this repository, you are given a simple task manager project that features basic CRUD operations on tasks. You are required to write unit tests for this project and apply mutation testing to improve your tests.

Note: We use poerty for dependency management, pytest for running tests and mutmut for mutation.

  1. Setup:

    • Ensure pytest and mutmut are installed: poetry add pytest poetry add mutmut
  2. Implementation:

    • Write tests for both modules of the project [Task, TaskManager] inside /tests/test_taskManager.py

Note: Build you tests inside of ./tests/test_taskManager.py see the test file and strictly follow the provided example.

  1. Execution:

    • Run tests using: poetry run pytest ./tests/test_taskManager.py
  2. Mutation testing:

    • Run mutmut using: poetry run mutmut run --paths-to-mutate ./taskManager/ --runner="pytest tests/test_taskManager.py
  3. Check results:

    • Use: poetry run mutmut show poetry run mutmut results
  4. Analyze survived mutations and improve tests:

    • Run: poetry run mutmut show <id>

Note: Requirements to pass: Minimum number of mutations to cover with tests: 20 For example: You will have a lot of mutations that are not meaningful. You have to get rid of them using # pragma: no mutate. Then when you have the set of meaningful mutations - you have to kill them using your tests.

Random Testing - Practical Assignment 2 (2pts)

InnoDrive - Problem

The InnoDrive is a hypothetical autonomous car-sharing service that provides transportation in the Kazan region and was created by SQR graduates from Innopolis. The service proposes two types of cars budget and luxury. The service offers flexible two tariff plans. With the “Minute” plan, the service charges its client by time per minute of use. The Service also proposes a “Fixed price” plan where the price is fixed at the reservation time when the route is chosen. If the driver deviates from the planned route for more than 10%, the tariff plan automatically switches to the “Minute” plan. The deviation is calculated as the difference in the distance or duration from the initially planned route. The “Fixed price” plan is available for budget cars only. The Innopolis city sponsors the mobility and offers a 10% discount to Innopolis residents.

You are a member of the quality assurance team at InnoDrive. You learned about input domain testing methods and would like to apply them to the billing application that charges the client when he or she completes the ride.

Note: the exact tariffs, deviation % and discount % will differ for your individual case see below.

InnoDrive Service

The InnoDrive app offers 2 services that can be accessed via the following URL https://instructors.pg.innopolis.university/innodrive/:

  • /spec - provides you with the specification for your individual problem

  • /rangeprice - calculate the price for a given ride. The possible input parameters are:

    • type={budget|luxury}
    • plan={fixed_price|minute}
    • distance=110
    • planned_distance=100
    • time=110
    • planned_time=100
    • inno_discount={yes|no}
  • the output is the price calculated according to the specification

    • In case of error, 406 Not Acceptable: is raised with the Error code: Price == -1
    • In case of the type error, 422 Unprocessable Entity is raised

Note: You can see the API and try the services at https://instructors.pg.innopolis.university/innodrive/docs

Tasks

The customers have discovered some anomalies in the InnoDrive services when applying minute plans for both types of cars. The input space is enormous, and exhaustive testing of all inputs is out of the question. With the help of the Hypothesis, identify at least one failing test case for time parameter in the range of 1-1000 minutes. Prevent exhaustive search and minimize executions.

Note: Build you tests inside of ./tests/test_innodrive.py see the test file and strictly follow the provided example.

Email: i.ivanov@innopolis.university

Note: Make sure to replace the email with your Innopolis email

Error in the Time range

Please replace each __ with a time parameter value in minutes for which a failure occurred. Example (100):

Note: Keep round brackets

  • Budget plan failure on Time = (___)

  • Luxury plan failure on Time = (___)

Useful resources

http://testdriven.io/blog/testing-python/

https://mutmut.readthedocs.io/en/latest/

https://hypothesis.readthedocs.io/en/latest/

https://www.inspiredpython.com/course/testing-with-hypothesis/testing-your-python-code-with-hypothesis