def test_config_get_non_existing_key(self): config = Config(type="environment") try: config.get("non-existing-key") assert False except ConfigurationError: assert True
def token_service_provider(requests_mock): config = Config(env="dev") config.config["tokenService"] = "http://localhost/token" response = json.dumps({ "access_token": from_cache_not_expired_token, "refresh_token": from_cache_not_expired_token, }) requests_mock.register_uri("POST", "http://localhost/token", text=response, status_code=200) return TokenServiceProvider(config, "username", "password")
def test_custom_config(self): custom_config = { "foo": "omg this cake tastes so good", "bar": "give me cheese" } config = Config(config=custom_config) assert config.config == custom_config
def __init__(self, config=None, auth=None, env=None): self.config = config if self.config is None: log.info("Initializing configuration object") self.config = Config(env=env) self.auth = auth if self.auth is None: log.info("Initializing auth object") self.auth = Authenticate(self.config)
from origo.file_cache import FileCache from origo.config import Config config = Config() def test_write_client_credentials(): fc = FileCache(config) fc.credentials_cache_enabled = True cc = {"access_token": "yo", "refresh_token": "bro"} fc.write_credentials(cc) assert cc.__eq__(fc.read_credentials()) def test_disable_cache(): fc = FileCache(config) fc.credentials_cache_enabled = False cc = {"access_token": "yo-bro", "refresh_token": "zup-dawg"} fc.write_credentials(cc) assert fc.read_credentials() is None
# Raspberrypi/Haraldrud #RIKTIG FIL!## import pprint import sys import os import time import serial from datetime import datetime from origo.event.post_event import PostEvent from origo.config import Config import gspread from oauth2client.service_account import ServiceAccountCredentials post_event = PostEvent(Config()) scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] credentials_path = "/home/pi/ren-besoksteller-gjenbrukstasjoner/credentials.json" credentials = ServiceAccountCredentials.from_json_keyfile_name( credentials_path, scope) gc = gspread.authorize(credentials) teller = 0 timer = 0 OLD_MINUTTER = 1 OLDDATE = 0 error = 0 day = 0 ser_bytes = serial.Serial('/dev/ttyUSB0', 9600)
def test_config_get_existing_key(self): config = Config(type="environment") assert config.get("client_id") == "my-origio-user" assert config.get("client_secret") == "my-origo-password"
def test_create_invalid_configuration(self): try: Config(type="foobar") assert False except ConfigurationError: assert True