Skip to content

Commit

Permalink
chore(CI): fix CI workflows (AlertaDengue#214)
Browse files Browse the repository at this point in the history
* fix(CI): fix CI workflows

* run pre-commit

* include pre-commit before testing

* include pre-commit before commiting

* linting pt.1

* linting pt.2

* replace mocked tests by endpoint tests

* remove compose-go

* linting pt.3 final
  • Loading branch information
luabida authored and felipeadeildo committed Nov 29, 2024
1 parent 59b2d50 commit 6433857
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pysus/ftp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import humanize
from aioftp import Client
from loguru import logger
from pysus.data.local import Data
from tqdm import tqdm
from typing_extensions import Self

from pysus.data.local import Data

# Type aliases
PathLike = Union[str, pathlib.Path]
FileContent = Dict[str, Union["Directory", "File"]]
Expand Down Expand Up @@ -403,7 +402,9 @@ def load_directory_content(path: str) -> FileContent:
def line_parser(line: str):
if "<DIR>" in line:
date, time, _, name = line.strip().split(maxsplit=3)
modify = datetime.strptime(f"{date} {time}", "%m-%d-%y %I:%M%p")
modify = datetime.strptime(
f"{date} {time}", "%m-%d-%y %I:%M%p"
)
info = {"size": 0, "type": "dir", "modify": modify}
xpath = f"{path}/{name}"
content[name] = Directory(xpath)
Expand Down Expand Up @@ -481,7 +482,9 @@ def content(self) -> List[Union[Directory, File]]:
inside content, `load()` the directory and call `content` again.
"""
if not self.__content__:
logger.info("content is not loaded, use `load()` to load default paths")
logger.info(
"content is not loaded, use `load()` to load default paths"
)
return []
return sorted(list(self.__content__.values()), key=str)

Expand Down Expand Up @@ -546,7 +549,9 @@ def get_files(self, *args, **kwargs) -> list[File]:
"""
...

def download(self, files: List[File], local_dir: str = CACHEPATH) -> List[str]:
def download(
self, files: List[File], local_dir: str = CACHEPATH
) -> List[str]:
"""
Downloads a list of Files.
"""
Expand All @@ -561,7 +566,9 @@ def download(self, files: List[File], local_dir: str = CACHEPATH) -> List[str]:
return dfiles[0]
return dfiles

async def async_download(self, files: List[File], local_dir: str = CACHEPATH):
async def async_download(
self, files: List[File], local_dir: str = CACHEPATH
):
"""
Asynchronously downloads a list of files
"""
Expand Down
8 changes: 8 additions & 0 deletions pysus/tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

import pandas as pd
from pysus.data.local import ParquetSet
<<<<<<< HEAD
from pysus.ftp import DIRECTORY_CACHE, Database, Directory, File
=======
from pysus.ftp import CACHE, Database, Directory, File
>>>>>>> 0a98978 (chore(CI): fix CI workflows (#214))
from pysus.ftp.databases import (
ciha,
cnes,
Expand Down Expand Up @@ -64,7 +68,11 @@ def test_root_directory(self):
self.assertTrue(self.root.parent == self.root) # outermost parent

def test_directory_cache(self):
<<<<<<< HEAD
self.assertTrue(DIRECTORY_CACHE["/"] == self.root)
=======
self.assertTrue(CACHE["/"] == self.root)
>>>>>>> 0a98978 (chore(CI): fix CI workflows (#214))

def test_sinan_file(self):
file = Directory("/dissemin/publicos/SINAN/DADOS/FINAIS").content[0]
Expand Down

0 comments on commit 6433857

Please sign in to comment.