예제 #1
0
    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)
예제 #2
0
 def __buildService(self, accessor):
     if self.cacheDuration > 0:
         return ViCareCachedService(self.oauth_manager, accessor,
                                    self.cacheDuration)
     else:
         return ViCareService(self.oauth_manager, accessor)
예제 #3
0
 def setUp(self):
     self.oauth_mock = Mock()
     accessor = ViCareDeviceAccessor("[id]", "[serial]", "[device]")
     self.service = ViCareService(self.oauth_mock, accessor)