Пример #1
0
# Create and configure logger
LOG_FORMAT = "%(asctime)s : %(levelname)s - %(message)s"
logging.basicConfig(filename="logs/start.py.log",
                    level=logging.DEBUG,
                    format=LOG_FORMAT)

# Check the environment
env = os.environ.get('ENVIRONMENT')
if env == None:
    logging.info('No environment supplied. Hence defaulting to dev')
    env = 'dev'

# Source environment specific settings file
_settingsFile = os.path.join("settings", "app.settings." + env + ".json")
util = Utils()
settings = util.getSettings(_settingsFile)
api = BooksAPI(settings)

# Get Books from API
print(
    "#############################################################################"
)
print(
    "#################### Get Ratings List #######################################"
)
print(
    "#############################################################################"
)
logging.info('Starting request to API to get list of ratings')
apiBookRatingsUrl = settings['apiUrl'] + 'bookrating/'
_bookRatingJson = api.getRequest(apiBookRatingsUrl)
Пример #2
0
 def test_getSettings(self):
     _settingsFile = os.path.join("../settings",
                                  "app.settings." + env + ".json")
     util = Utils()
     settings = util.getSettings(_settingsFile)
     assert 'apiUrl' in settings