def test_should_raise_config_error_when_missing_env_variable(self, os_mock):
        os_mock.environ = {
            'MONGO_HOST': 'mock-host',
        }

        with self.assertRaises(ConfigError):
            get_config()
    def setUp(self) -> None:
        configurations = get_config()
        mongo_client = pymongo.MongoClient(configurations.MONGO_HOST,
                                           int(configurations.MONGO_PORT))
        self.database = mongo_client[configurations.MONGO_DB]
        self.collection = self.database[
            configurations.MONGO_PODCAST_COLLECTION]
        self.podcast_repository = PodcastRepository(self.collection)

        self.podcast = Podcast(
            name='Flow Podcast',
            rss='https://rss-feed-flowpodcast-2eqj3fl3la-ue.a.run.app/feed/rss'
        )
    def test_should_get_configurations(self, os_mock):
        os_mock.environ = {
            'MONGO_HOST': 'mock-host',
            'MONGO_PORT': 'mock-port',
            'MONGO_DB': 'mock-db',
            'MONGO_PODCAST_COLLECTION': 'mock-podcast-collection',
            'MONGO_EPISODE_COLLECTION': 'mock-episode-collection'
        }

        configurations = get_config()
        self.assertIsInstance(configurations, Config)
        self.assertEqual(configurations.MONGO_HOST, 'mock-host')
        self.assertEqual(configurations.MONGO_PORT, 'mock-port')
    def setUp(self) -> None:
        configurations = get_config()
        mongo_client = pymongo.MongoClient(configurations.MONGO_HOST,
                                           int(configurations.MONGO_PORT))
        self.database = mongo_client[configurations.MONGO_DB]
        self.collection = self.database[
            configurations.MONGO_EPISODE_COLLECTION]
        self.episode_repository = EpisodeRepository(self.collection)

        self.episode = Episode(
            name='ANDRÉ VIANCO - Flow Podcast #279',
            podcast='Flow Podcast',
            image=
            'https://artworks-flow.s3-sa-east-1.amazonaws.com/279_Andre_Vianco.jpg',
            description=
            'André Vianco é um escritor brabo que escreveu os livros que mais marcaram a vida do Monark',
            audio='https://content.blubrry.com/flowpdc/279_ANDRE_VIANCO.mp3')
Beispiel #5
0
# -*- coding: utf-8 -*-

from flask import Flask
from flask_restful import Api

from src import configurations

config = configurations.get_config()

web_app = None
api = None


def get_web_app() -> Flask:
    global web_app

    if not web_app:
        web_app = Flask(__name__)
        web_app.config.from_object(config)

    return web_app


def get_api() -> Api:
    global api

    if not api:
        api = Api(get_web_app())
    return api
Beispiel #6
0
from src import web_app as web_app_module, configurations as config_module, endpoints
from src import aws as aws_module
from src import PodcastService, TranscribeService
from src.domain import DomainService
from src.infrascructure import CacheRepository
from src.infrascructure import create_repository
from src.rss_reader import RssReader
from src.transcribe import AWSTranscribe

web_app = web_app_module.get_web_app()
api = web_app_module.get_api()
configurations = config_module.get_config()
transcribe_client = aws_module.get_transcribe_client()
s3_client = aws_module.get_s3_client()

cache_repository = CacheRepository()
rss_reader = RssReader()
mongodb_repository = create_repository(configurations)
domain_service = DomainService()
aws_transcribe = AWSTranscribe(transcribe_client)

podcast_service = PodcastService(mongodb_repository, rss_reader,
                                 cache_repository, domain_service)
transcribe_service = TranscribeService(aws_transcribe, s3_client)

endpoints.register(podcast_service=podcast_service,
                   transcribe_service=transcribe_service)
 def test_should_raise_invalid_repository_when_given_a_invalid_type(
         self) -> None:
     with self.assertRaises(InvalidRepository):
         self.config = get_config()
         create_repository(self.config, 'bonus')
 def setUp(self) -> None:
     self.config = get_config()