Skip to content

xarpy/tp_challenges

Repository files navigation

TP Challenges

Python Version

A collection of interesting challenges to improve technical skills and test new skills

Installation

Environment Local

Using your dependency manager, create a python environment, follow a link talking about the managers!

Access the project folder and using the pip manager, inside the python env, apply the command below:

Upgrade pip version and install requirements and install:

pip install --upgrade pip && pip install --require-hashes -r requirements/dev.txt

After installing all dependencies,compile this project with command:

python -m spacy download en_core_web_sm && playwright install

And to run each script, just use the command below:

python -m scripts.<module-you-want-test>

If it is a script that accepts arguments, just pass arguments like this:

python -m scripts.<module-you-want-test> paramenter

Docker Build

You will need to have docker compose, and finally apply the command:

docker compose up --build

After build project, in another terminal, apply the command:

docker exec -it telescopes python -m scripts.<module-you-want-test>

or

docker compose run telescopes python -m scripts.<module-you-want-test>

If it is a script that accepts arguments, just pass arguments like this:

docker exec -it telescopes python -m scripts.<module-you-want-test> paramenter

or

docker compose run telescopes python -m scripts.<module-you-want-test> paramenter

Obs:

  • For practical use of the application it is necessary to add single quotes, making it a valid argument.
  • the search_engine script was tested with an exact file search argument.
  • By default, the second and third scripts do not accept headless mode arguments, making it necessary to activate it manually in the script.
  • We recommend creating the credentials for using the search_engine script in the examples folder, otherwise it won't work with the name google-drive.json.
  • It's necessary to define the environment variables in the .env file, just read the file itself, as it is self-suggestive.

Dependencies

This project uses hashed dependencies. To update them, edit requirements/base.in for project dependencies and requirements/dev.in for development dependencies and run:

pip-compile --generate-hashes --output-file requirements/base.txt requirements/base.in && \
pip-compile --generate-hashes --output-file requirements/dev.txt requirements/dev.in

It is always necessary to pip-compile both because dev-deps references base-deps.

Usage

In order to be able to normalize, we add the best practices in this project, aiming to respect the principles with example Clean Code, SOLID and others. For more details, see the tip links!

Formatters and Linters

Obs:

  • Programming with Python, we use the snake_case style for variables, functions and methods, and the PascalCase style for classes. Configuration variables should written in UPPERCASE.

Structure

We use the microservices architecture patterns with DDD principle, to create system resources. To example, see the content:

./
├── examples/
│   ├── companies_linkedin.csv
│   └──  g2_urls.csv
├── requirements/
│   ├── base.in
│   ├── base.txt
│   ├── dev.in
│   └── dev.txt
├── scripts/
│   ├──company_details.py
│   ├── count_employees.py
│   ├── __init__.py
│   └──search_engine.py
├── tests/
├── docker-compose.yml
├── Dockerfile
├── env.example
├── LICENSE
├── pyproject.toml
└── README.md

Tests

In this application, we used this dependencies to perform, scan and cover tests in the application:

In this application, unit tests were created, using pytest. Follow the instructions to run the tests. The commands are the same for both settings, just the environment follow belou the steps:

Environment Local

  • To see tests list
pytest --co
  • To run all test
pytest tests/
  • To run only test module
pytest tests/<module-you-want-test>.py
  • To run only function test module
pytest tests/<module-you-want-test>.py::<function_teste_name>

Container Environment

  • To see tests list
docker compose run telescopes pytest --co
  • To run all test
docker compose run telescopes pytest tests/
  • To run only test module
docker compose run telescopes pytest tests/<module-you-want-test>.py
  • To run only function test module
docker compose run telescopes tests/<module-you-want-test>.py::<function_teste_name>

Obs:

  • Any doubts about the use or how pytest works, in the resources section we provide a direct link to the tool's documentation.

Resources and Documentations

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

About

Creating scripts for testing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published