def __init__(self, username, password, token_file=None, circuit=0, cacheDuration=0): """Init function. Create the necessary oAuth2 sessions Parameters ---------- username : str e-mail address password : str password Returns ------- """ if cacheDuration == 0: self.service = ViCareService(username, password, token_file, circuit) else: self.service = ViCareCachedService(username, password, cacheDuration, token_file, circuit)
def __buildService(self, accessor): if self.cacheDuration > 0: return ViCareCachedService(self.oauth_manager, accessor, self.cacheDuration) else: return ViCareService(self.oauth_manager, accessor)
def setUp(self): self.oauth_mock = Mock() accessor = ViCareDeviceAccessor("[id]", "[serial]", "[device]") self.service = ViCareService(self.oauth_mock, accessor)