From c0a0d3825af73d96432b94f4ebdd36958ef9b7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nelson=20Guam=C3=A1n?= Date: Sat, 14 Dec 2024 14:57:51 +0000 Subject: [PATCH] fix: minor fixes and first notebook --- notebooks/.keep | 0 notebooks/tender_by_code.ipynb | 143 ++++++++++++++++++++++++++++++ src/licitpy/entities/tender.py | 2 +- tests/integration/test_parsers.py | 3 +- tests/integration/test_url.py | 1 + 5 files changed, 147 insertions(+), 2 deletions(-) delete mode 100644 notebooks/.keep create mode 100644 notebooks/tender_by_code.ipynb diff --git a/notebooks/.keep b/notebooks/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/notebooks/tender_by_code.ipynb b/notebooks/tender_by_code.ipynb new file mode 100644 index 0000000..1544dff --- /dev/null +++ b/notebooks/tender_by_code.ipynb @@ -0,0 +1,143 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: licitpy in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (0.8.1)\n", + "Requirement already satisfied: tabulate in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (0.9.0)\n", + "Requirement already satisfied: lxml<6.0.0,>=5.3.0 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (5.3.0)\n", + "Requirement already satisfied: pandas<3.0.0,>=2.2.3 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (2.2.3)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.9.2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (2.10.3)\n", + "Requirement already satisfied: python-dateutil<3.0.0,>=2.9.0.post0 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (2.9.0.post0)\n", + "Requirement already satisfied: python-magic<0.5.0,>=0.4.27 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (0.4.27)\n", + "Requirement already satisfied: requests<3.0.0,>=2.32.3 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (2.32.3)\n", + "Requirement already satisfied: requests-cache<2.0.0,>=1.2.1 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (1.2.1)\n", + "Requirement already satisfied: tenacity<10.0.0,>=9.0.0 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (9.0.0)\n", + "Requirement already satisfied: tqdm<5.0.0,>=4.67.0 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from licitpy) (4.67.1)\n", + "Requirement already satisfied: numpy>=1.23.2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pandas<3.0.0,>=2.2.3->licitpy) (2.2.0)\n", + "Requirement already satisfied: pytz>=2020.1 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pandas<3.0.0,>=2.2.3->licitpy) (2024.2)\n", + "Requirement already satisfied: tzdata>=2022.7 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pandas<3.0.0,>=2.2.3->licitpy) (2024.2)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.9.2->licitpy) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.27.1 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.9.2->licitpy) (2.27.1)\n", + "Requirement already satisfied: typing-extensions>=4.12.2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.9.2->licitpy) (4.12.2)\n", + "Requirement already satisfied: six>=1.5 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from python-dateutil<3.0.0,>=2.9.0.post0->licitpy) (1.17.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.32.3->licitpy) (3.4.0)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.32.3->licitpy) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.32.3->licitpy) (2.2.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests<3.0.0,>=2.32.3->licitpy) (2024.8.30)\n", + "Requirement already satisfied: attrs>=21.2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests-cache<2.0.0,>=1.2.1->licitpy) (24.2.0)\n", + "Requirement already satisfied: cattrs>=22.2 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests-cache<2.0.0,>=1.2.1->licitpy) (24.1.2)\n", + "Requirement already satisfied: platformdirs>=2.5 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests-cache<2.0.0,>=1.2.1->licitpy) (4.3.6)\n", + "Requirement already satisfied: url-normalize>=1.4 in /home/nguaman/Escritorio/dev/projects/licitpy/.venv/lib/python3.11/site-packages (from requests-cache<2.0.0,>=1.2.1->licitpy) (1.4.3)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], + "source": [ + "%pip install licitpy tabulate" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.8.1\n" + ] + } + ], + "source": [ + "import licitpy\n", + "print(licitpy.__version__)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "licitpy = licitpy.Licitpy()\n", + "tender = licitpy.tenders.from_code(\"2446-900-L124\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| Field | Value |\n", + "+==============+===========================================================================================================+\n", + "| url | https://www.mercadopublico.cl/Procurement/Modules/RFB/DetailsAcquisition.aspx?qs=0AP9GbyUyyoqNYGyeIx2+w== |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| code | 2446-900-L124 |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| title | ADQUISICIÓN DE MATERIALES PARA REPARACIÓN DE LA DEPENDENCIA DE LA CRUZ DEL III MILENIO |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| status | Status.CLOSED |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| opening_date | 2024-12-02 15:17:15-03:00 |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| closing_date | 2024-12-09 15:06:00-03:00 |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n", + "| region | Region.IV |\n", + "+--------------+-----------------------------------------------------------------------------------------------------------+\n" + ] + } + ], + "source": [ + "from tabulate import tabulate\n", + "\n", + "data = {\n", + " \"url\": tender.url,\n", + " \"code\": tender.code,\n", + " \"title\": tender.title,\n", + " \"status\": tender.status,\n", + " \"opening_date\": tender.opening_date,\n", + " \"closing_date\": tender.closing_date,\n", + " \"region\": tender.region,\n", + "}\n", + "\n", + "table = tabulate(data.items(), headers=[\"Field\", \"Value\"], tablefmt=\"grid\")\n", + "\n", + "print(table)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.11" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/src/licitpy/entities/tender.py b/src/licitpy/entities/tender.py index 3490adb..02eafdb 100644 --- a/src/licitpy/entities/tender.py +++ b/src/licitpy/entities/tender.py @@ -1,6 +1,6 @@ from __future__ import annotations -from datetime import date, datetime +from datetime import datetime from typing import List, Optional from pydantic import HttpUrl diff --git a/tests/integration/test_parsers.py b/tests/integration/test_parsers.py index be9d35d..66a16dc 100644 --- a/tests/integration/test_parsers.py +++ b/tests/integration/test_parsers.py @@ -1,5 +1,6 @@ from datetime import datetime from zoneinfo import ZoneInfo + import pytest import requests @@ -76,7 +77,7 @@ def test_closing_date_from_ocds( def test_closing_date_with_eligibility_closing_date( tender_parser: TenderParser, tender_url_with_eligibility_closing_date: str ) -> None: - + response = requests.get(tender_url_with_eligibility_closing_date) assert ( diff --git a/tests/integration/test_url.py b/tests/integration/test_url.py index f62db2c..5c498e9 100644 --- a/tests/integration/test_url.py +++ b/tests/integration/test_url.py @@ -13,6 +13,7 @@ def test_url_status() -> None: response.status_code == 200 ), f"Expected status 200, got {response.status_code}" + @pytest.mark.integration def test_url_api_ocds() -> None: """