Skip to content

Commit

Permalink
wip: test
Browse files Browse the repository at this point in the history
  • Loading branch information
polomarcus committed Feb 14, 2025
1 parent fc5abdd commit d1d5936
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ UPDATE stop_word set validated=false WHERE id = 'MY_ID';
* Use scaleway
* Use [Ray dashboard] on port 8265

## Bump version
[poetry bump](https://python-poetry.org/docs/cli/#version)
```
poetry version minor
```

## Materialized view - dbt
Using [DBT](https://www.getdbt.com/), used via docker :
Expand Down
5 changes: 3 additions & 2 deletions postgres/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ def update_program_metadata(engine):
except (Exception) as error:
logging.error(f"Error : Update program metadata {error}")

def empty_tables(session = None):
def empty_tables(session = None, stop_word = True):
if(os.environ.get("POSTGRES_HOST") == "postgres_db" or os.environ.get("POSTGRES_HOST") == "localhost"):
logging.warning("""Doing: Empty table Stop_Word / Keywords""")
session.query(Stop_Word).delete()
if stop_word:
session.query(Stop_Word).delete()
session.query(Keywords).delete()
session.commit()
logging.warning("""Done: Empty table Stop_Word / Keywords""")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "quotaclimat"
version = "1.0.78"
version = "1.1.0"
description = ""
authors = [
{name = "Rambier Estelle", "email"="[email protected]"},
Expand Down
6 changes: 2 additions & 4 deletions test/sitemap/test_main_import_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def insert_mediatree_json(conn, json_file_path='test/sitemap/mediatree.json'):
# create_tables()
empty_tables(get_db_session(conn))
empty_tables(get_db_session(conn), stop_word=False)
logging.info(f"reading {json_file_path}")
with open(json_file_path, 'r') as file:
json_response = json.load(file)
Expand Down Expand Up @@ -104,12 +104,10 @@ def test_third_row_api_import():
,"ressources_solutions_indirectes"
])


assert specific_keyword.number_of_keywords == 1


def test_get_api_stop():
conn = connect_to_db()
session = get_db_session(conn)
stopwords = get_stop_words(session)
assert type(stopwords[0]) == str
assert type(stopwords[0]) == str
1 change: 1 addition & 0 deletions test/sitemap/test_mediatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from test_utils import get_localhost, debug_df
from quotaclimat.data_processing.mediatree.api_import import *
from quotaclimat.data_processing.mediatree.utils import *
from quotaclimat.data_processing.mediatree.s3.api_to_s3 import *
from postgres.insert_data import save_to_pg
from postgres.schemas.models import keywords_table, connect_to_db, get_keyword, drop_tables, empty_tables

Expand Down

1 comment on commit d1d5936

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
postgres
   insert_data.py43784%36–38, 57–59, 64
   insert_existing_data_example.py19384%25–27
postgres/schemas
   models.py1981692%152–153, 156–163, 172, 179, 181–182, 247–248, 254, 268, 275–276
quotaclimat/data_ingestion
   scrap_sitemap.py1341787%27–28, 33–34, 66–71, 95–97, 138–140, 202, 223–228
quotaclimat/data_ingestion/ingest_db
   ingest_sitemap_in_db.py553733%21–42, 45–58, 62–73
quotaclimat/data_ingestion/scrap_html
   scrap_description_article.py36392%19–20, 32
quotaclimat/data_processing/mediatree
   api_import.py16411033%43–78, 82–85, 91, 100, 106, 109–111, 114–135, 138–174, 177–208, 211–213
   channel_program.py1695667%21–23, 34–36, 53–54, 57–59, 98–99, 124, 175–216
   config.py15287%7, 16
   detect_keywords.py260797%127–128, 289, 361–363, 405
   update_pg_keywords.py916726%16–19, 22–31, 36–157, 181, 184, 188–189, 199–220, 254–291, 301
   utils.py962970%29–53, 56, 65, 138–141, 145–152
quotaclimat/data_processing/mediatree/api_import_utils
   db.py22386%46–48
quotaclimat/data_processing/mediatree/s3
   api_to_s3.py19111639%41–56, 61, 114–115, 118–122, 128, 134–146, 150–156, 159–163, 166–192, 195–245, 248–274, 277–279
   s3_utils.py843855%21–22, 34–41, 53–67, 70–82, 86–99, 122–125
quotaclimat/data_processing/mediatree/stop_word
   main.py16210833%40–44, 73, 90–110, 120–191, 195–259, 264–291, 295–338, 341–343
quotaclimat/utils
   healthcheck_config.py291452%22–24, 27–38
   logger.py241154%22–24, 28–37
   sentry.py11282%22–23
TOTAL183064665% 

Tests Skipped Failures Errors Time
116 0 💤 0 ❌ 0 🔥 5m 32s ⏱️

Please sign in to comment.