Пример #1
0
 def get_profile_photo(self, size='medium'):
     if size not in ('small', 'medium', 'large'):
         raise InvalidSizeException('User get_profile_photo size must one of "small", "medium" or "large".')
     from mapmyfitness import MapMyFitness
     instance = MapMyFitness.instance()
     user_profile_photo = instance._user_profile_photo.find(self.id)
     return getattr(user_profile_photo, size)
Пример #2
0
 def get_profile_photo(self, size='medium'):
     if size not in ('small', 'medium', 'large'):
         raise InvalidSizeException(
             'User get_profile_photo size must one of "small", "medium" or "large".'
         )
     from mapmyfitness import MapMyFitness
     instance = MapMyFitness.instance()
     user_profile_photo = instance._user_profile_photo.find(self.id)
     return getattr(user_profile_photo, size)
Пример #3
0
 def activity_type(self):
     if hasattr(self, '_activity_type'):
         return self._activity_type
     else:
         from mapmyfitness import MapMyFitness
         instance = MapMyFitness.instance()
         activity_type = instance.activity_type.find(self.activity_type_id)
         self._activity_type = activity_type
         return self._activity_type
Пример #4
0
 def route(self):
     if self.route_id:
         if hasattr(self, '_route'):
             return self._route
         else:
             from mapmyfitness import MapMyFitness
             instance = MapMyFitness.instance()
             route = instance.route.find(self.route_id)
             self._route = route
             return self._route
Пример #5
0
    def activity_type(self):
        if hasattr(self, "_activity_type"):
            return self._activity_type
        else:
            from mapmyfitness import MapMyFitness

            instance = MapMyFitness.instance()
            activity_type = instance.activity_type.find(self.activity_type_id)
            self._activity_type = activity_type
            return self._activity_type
Пример #6
0
 def route(self):
     if self.route_id:
         if hasattr(self, '_route'):
             return self._route
         else:
             from mapmyfitness import MapMyFitness
             instance = MapMyFitness.instance()
             route = instance.route.find(self.route_id)
             self._route = route
             return self._route
 def root_activity_type(self):
     if not self.has_parent:
         return self
     if hasattr(self, '_activity_type'):
         return self._activity_type
     else:
         from mapmyfitness import MapMyFitness
         instance = MapMyFitness.instance()
         activity_type = instance.activity_type.find(self.root_activity_type_id)
         self._activity_type = activity_type
         return self._activity_type
Пример #8
0
 def time_series(self):
     if self.has_time_series:
         if 'time_series' in self.original_dict:
             return self.original_dict['time_series']
         elif hasattr(self, '_time_series'):
             return self._time_series
         else:
             from mapmyfitness import MapMyFitness
             instance = MapMyFitness.instance()
             workout = instance.workout.find(self.id)
             self._time_series = workout.time_series
             return self._time_series
Пример #9
0
 def time_series(self):
     if self.has_time_series:
         if 'time_series' in self.original_dict:
             return self.original_dict['time_series']
         elif hasattr(self, '_time_series'):
             return self._time_series
         else:
             from mapmyfitness import MapMyFitness
             instance = MapMyFitness.instance()
             workout = instance.workout.find(self.id)
             self._time_series = workout.time_series
             return self._time_series
Пример #10
0
    def __getattr__(self, name):
        # First checking to see if we're entering a recursion
        # cycle, and if so exiting immediately. Calling `hasattr(self, name)`
        # will call getattr(self, name) itself and therefore keep recursing.
        if '__getattr__' in inspect.stack()[1]:
            raise AttributeNotFoundException

        from mapmyfitness import MapMyFitness
        instance = MapMyFitness.instance()
        user = instance.user.find(self.id)
        self.__init__(user.original_dict)

        return getattr(self, name)
Пример #11
0
    def __getattr__(self, name):
        # First checking to see if we're entering a recursion
        # cycle, and if so exiting immediately. Calling `hasattr(self, name)`
        # will call getattr(self, name) itself and therefore keep recursing.
        if '__getattr__' in inspect.stack()[1]:
            raise AttributeNotFoundException

        from mapmyfitness import MapMyFitness
        instance = MapMyFitness.instance()
        user = instance.user.find(self.id)
        self.__init__(user.original_dict)

        return getattr(self, name)
 def tearDown(self):
     MapMyFitness._drop()
    def test_MapMyFitness_instance(self):
        MapMyFitness('api-key', 'access_token')

        assert MapMyFitness.instance()
 def test_MapMyFitness_singleton_not_initialized(self):
     MapMyFitness._drop()
     self.assertRaises(NotInitializedException, MapMyFitness.instance)
Пример #15
0
    def test_MapMyFitness_is_singleton(self):
        mmf1 = MapMyFitness('api-key1', 'access_token1')
        mmf2 = MapMyFitness('api-key2', 'access_token2')

        assert mmf1 == mmf2
Пример #16
0
 def tearDown(self):
     MapMyFitness._drop()
Пример #17
0
    def test_MapMyFitness_instance(self):
        MapMyFitness('api-key', 'access_token')

        assert MapMyFitness.instance()
Пример #18
0
 def get_friends(self):
     from mapmyfitness import MapMyFitness
     instance = MapMyFitness.instance()
     friends = instance.user.search(friends_with=self.id)
     return friends
Пример #19
0
 def setUp(self):
     self.mmf = MapMyFitness(api_key='abc123',
                             access_token='super-secret-token')
Пример #20
0
 def get_friends(self):
     from mapmyfitness import MapMyFitness
     instance = MapMyFitness.instance()
     friends = instance.user.search(friends_with=self.id)
     return friends
Пример #21
0
from mapmyfitness import MapMyFitness

z = MapMyFitness(api_key='vd9aadfjcrd6ncae2wx92mc8tm4zfnx2',
                 access_token='21933fbf63aad3d8a49dde82d703fbbff3dbc727')
print z.user.find("self/")
Пример #22
0
 def test_MapMyFitness_singleton_not_initialized(self):
     MapMyFitness._drop()
     self.assertRaises(NotInitializedException, MapMyFitness.instance)