Skip to content

Commit

Permalink
Merge pull request #81 from rapyuta-robotics/devel
Browse files Browse the repository at this point in the history
🎉 release: v1.15.2
  • Loading branch information
ankitrgadiya authored Jun 27, 2024
2 parents 8fcc9d6 + 5834b1e commit 277ef18
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
7 changes: 6 additions & 1 deletion rapyuta_io/clients/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ class Device(PartialMixin, ObjDict):

def __init__(self, name, runtime=None, runtime_docker=False, runtime_preinstalled=False, ros_distro=None,
rosbag_mount_path=None,
ros_workspace=None, description=None, python_version=DevicePythonVersion.PYTHON2):
ros_workspace=None, description=None, python_version=DevicePythonVersion.PYTHON2,
config_variables=None, labels=None):
self.validate(name, runtime, runtime_docker, runtime_preinstalled, ros_distro, rosbag_mount_path, ros_workspace,
description, python_version)
self.name = name
Expand All @@ -272,6 +273,8 @@ def __init__(self, name, runtime=None, runtime_docker=False, runtime_preinstalle
self._ros_workspace = ros_workspace
self.description = description
self.python_version = python_version
self.config_variables = config_variables or {}
self.labels = labels or {}

@staticmethod
def validate(name, runtime, runtime_docker, runtime_preinstalled, ros_distro, rosbag_mount_path,
Expand Down Expand Up @@ -320,6 +323,8 @@ def _serialize(self):
'_ros_workspace']:
if getattr(self, field):
device['config_variables'][field[1:]] = getattr(self, field)
device['config_variables'].update(self.config_variables)
device['labels'] = self.labels
return device

@classmethod
Expand Down
34 changes: 28 additions & 6 deletions tests/device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ def test_create_device_dockercompose_success(self, mock_request):
'runtime_docker': True,
'ros_distro': 'melodic',
'rosbag_mount_path': 'test/path'
}
},
'labels': {}
}
expected_create_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/auth-keys/?download_type=script'
expected_get_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/devices/test-device-id'
Expand Down Expand Up @@ -610,7 +611,8 @@ def test_create_device_preinstalled_success(self, mock_request):
'runtime_preinstalled': True,
'ros_distro': 'melodic',
'ros_workspace': 'test/path'
}
},
'labels': {}
}
expected_create_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/auth-keys/?download_type=script'
expected_get_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/devices/test-device-id'
Expand Down Expand Up @@ -654,13 +656,22 @@ def test_create_device_dockercompose_success(self, mock_request):
'runtime_docker': True,
'runtime_preinstalled': True,
'ros_distro': 'melodic',
'rosbag_mount_path': 'test/path'
'rosbag_mount_path': 'test/path',
'custom-config-variable-1': 'value1',
'custom-config-variable-2': 'value2'
},
'labels': {
'custom-label-1': 'label1',
'custom-label-2': 'label2',
'custom-label-3': 'label3'
}
}
expected_create_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/auth-keys/?download_type=script'
expected_get_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/devices/test-device-id'
device = Device(name='test-device', runtime_docker=True, runtime_preinstalled=True,
ros_distro=ROSDistro.MELODIC, rosbag_mount_path='test/path', description='test-description')
ros_distro=ROSDistro.MELODIC, rosbag_mount_path='test/path', description='test-description',
config_variables={'custom-config-variable-1': 'value1','custom-config-variable-2': 'value2'},
labels={'custom-label-1': 'label1','custom-label-2': 'label2','custom-label-3': 'label3'})
create_device_response = Mock()
create_device_response.text = CREATE_BOTH_RUNTIMES_DEVICE_SUCCESS
create_device_response.status_code = requests.codes.OK
Expand All @@ -683,11 +694,21 @@ def test_create_device_dockercompose_success(self, mock_request):
expected_configs = {
'runtime': 'dockercompose',
'ros_distro': 'melodic',
'rosbag_mount_path': 'test/path'
'rosbag_mount_path': 'test/path',
'custom-config-variable-1': 'value1',
'custom-config-variable-2': 'value2',
}
for config in device.config_variables:
if config.key in expected_configs:
self.assertEqual(expected_configs[config.key], config.value)
expected_labels = {
'custom-label-1': 'label1',
'custom-label-2': 'label2',
'custom-label-3': 'label3'
}
for label in device.labels:
if label.key in expected_labels:
self.assertEqual(expected_labels[label.key], label.value)

@patch('requests.request')
def test_onboard_script_dockercompose_success(self, mock_request):
Expand Down Expand Up @@ -893,7 +914,8 @@ def test_create_device_python3_dockercompose_success(self, mock_request):
'runtime_docker': True,
'ros_distro': 'melodic',
'rosbag_mount_path': 'test/path'
}
},
'labels': {}
}
expected_create_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/auth-keys/?download_type=script'
expected_get_device_url = 'https://gaapiserver.apps.okd4v2.prod.rapyuta.io/api/device-manager/v0/devices/test-device-id'
Expand Down

0 comments on commit 277ef18

Please sign in to comment.