示例#1
0
 def test_env_load(self):
     """Get user_env from redis"""
     self.r.set('BOT_STATUS.user_env.testkey', self.testvalue)
     self.assertEqual(
         ENV.redis_load('user_env', name='testkey',
                        get_json=False, other_redis=self.r),
         self.testvalue)
示例#2
0
 def _get_raw_coordinate_values(self, redis=None):
     temp = []
     legacy = int(os.getenv('FARMBOT_OS_VERSION', '0.0.0')[0]) < 6
     if legacy:
         for axis in ['x', 'y', 'z']:
             temp.append(
                 ENV.redis_load('location_data.position.' + axis,
                                other_redis=redis))
     else:
         state = self._get_bot_state()
         for axis in ['x', 'y', 'z']:
             try:
                 value = state['location_data']['position'][str(axis)]
             except KeyError:
                 value = None
             temp.append(value)
     return temp
示例#3
0
 def _get_raw_coordinate_values(self, redis=None):
     temp = []
     if USE_FARMWARE_TOOLS and redis is None:
         coord = device.get_current_position() or {}
         return [coord.get('x'), coord.get('y'), coord.get('z')]
     legacy = int(os.getenv('FARMBOT_OS_VERSION', '0.0.0')[0]) < 6
     if legacy:
         for axis in ['x', 'y', 'z']:
             temp.append(
                 ENV.redis_load('location_data.position.' + axis,
                                other_redis=redis))
     else:
         state = self._get_bot_state()
         for axis in ['x', 'y', 'z']:
             try:
                 value = state['location_data']['position'][str(axis)]
             except KeyError:
                 value = None
             temp.append(value)
     return temp
示例#4
0
 def test_none_user_env_load(self):
     """Try to get a non-existent user_env from redis"""
     self.assertEqual(
         ENV.redis_load('user_env', name='doesntexist', other_redis=self.r),
         None)
示例#5
0
 def test_bad_json_env_load(self):
     """Try to get bad json user_env from redis"""
     self.r.set('BOT_STATUS.user_env.testdata', self.badjson_string)
     self.assertEqual(
         ENV.redis_load('user_env', name='testdata', other_redis=self.r),
         None)
示例#6
0
 def test_json_env_load(self):
     """Get json user_env from redis"""
     self.r.set('BOT_STATUS.user_env.testdata', json.dumps(self.testjson))
     self.assertEqual(ENV.redis_load(
         'user_env', name='testdata', other_redis=self.r), self.testjson)