def test_find_project_replacing_dots_with_dashes(project_repository: DBProjectRepository, project_view: DBProjectView): project = ProjectStub.create(name=ProjectName('pepy-rocks')) project_repository.save_projects([project]) result = project_view.find('pepy.rocks') expected = ProjectProjection('pepy-rocks', project.downloads.value, []) assert result == expected
def test_find_project_ignoring_white_spaces(project_repository: DBProjectRepository, project_view: DBProjectView): project = ProjectStub.create(name=ProjectName('pepy')) project_repository.save_projects([project]) result = project_view.find(' pepy ') expected = ProjectProjection('pepy', project.downloads.value, []) assert result == expected
def test_find_project_ignoring_case(project_repository: DBProjectRepository, project_view: DBProjectView): project = ProjectStub.create(name=ProjectName("pepy")) project_repository.save_projects([project]) result = project_view.find("PEpy") expected = ProjectProjection("pepy", project.downloads.value, []) assert result == expected
ImportDownloadsFileHandler, UpdateDownloads, UpdateDownloadsHandler, ) from pepy.application.helper import AdminPasswordChecker from pepy.application.query import BadgeProvider, ProjectProvider, DownloadsNumberFormatter from pepy.domain.model import HashedPassword from pepy.infrastructure.bq_downloads_extractor import BQDownloadsExtractor from pepy.infrastructure.db_repository import DBProjectRepository from pepy.infrastructure.db_view import DBProjectView from ._config import DATABASE, BQ_CREDENTIALS_FILE, ADMIN_PASSWORD, LOGGING_FILE, DATABASE_ORATOR, LOGGING_DIR db_connection = psycopg2.connect(**DATABASE) db_orator = DatabaseManager(DATABASE_ORATOR) project_repository = DBProjectRepository(db_connection) db_project_view = DBProjectView(db_orator) command_bus = CommandBus() command_bus.subscribe(ImportDownloadsFile, ImportDownloadsFileHandler(project_repository)) downloads_formatter = DownloadsNumberFormatter() badge_query = BadgeProvider(db_project_view, downloads_formatter) project_provider = ProjectProvider(db_project_view) # Directories configuration if not os.path.exists(LOGGING_DIR): os.makedirs(LOGGING_DIR) # Logger configuration logger = logging.getLogger("pepy") logger.setLevel(logging.INFO) formatter = logging.Formatter(
def project_view(): conn = container.db_orator yield DBProjectView(conn)