Skip to content

Commit f9a4b08

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit c771880
1 parent ea22167 commit f9a4b08

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/viam/app/app_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ async def update_organization(
756756
public_namespace (Optional[str]): If provided, sets the org's namespace if it hasn't already been set.
757757
region (Optional[str]): If provided, updates the org's region.
758758
cid (Optional[str]): If provided, update's the org's CRM ID.
759+
default_fragments (Optional[FragmentImportList]): If provided, updates the org's default fragments.
759760
760761
Raises:
761762
GRPCError: If the org's namespace has already been set, or if the provided namespace is already taken.

tests/mocks/services.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from numpy.typing import NDArray
88

99
from viam.app.data_client import DataClient
10-
from viam.gen.app.v1.app_pb2 import FragmentHistoryEntry, GetFragmentHistoryRequest, GetFragmentHistoryResponse
10+
from viam.gen.app.data import FragmentHistoryEntry, GetFragmentHistoryRequest, GetFragmentHistoryResponse
11+
from viam.gen.app.packages import FragmentImportList, PackageType
1112
from viam.media.video import ViamImage
1213
from viam.proto.app import (
1314
AddRoleRequest,
@@ -314,8 +315,6 @@
314315
TrainingJobMetadata,
315316
UnimplementedMLTrainingServiceBase,
316317
)
317-
from viam.proto.app.packages import PackageType
318-
from viam.proto.app.robot import ComponentConfig
319318
from viam.proto.common import (
320319
DoCommandRequest,
321320
DoCommandResponse,
@@ -1388,6 +1387,7 @@ def __init__(
13881387
api_keys_with_authorizations: List[APIKeyWithAuthorizations],
13891388
items: List[RegistryItem],
13901389
package_type: PackageType.ValueType,
1390+
default_fragments_for_org: Optional[FragmentImportList] = None,
13911391
):
13921392
self.organizations = organizations
13931393
self.location = location
@@ -1411,6 +1411,7 @@ def __init__(
14111411
self.api_keys_with_authorizations = api_keys_with_authorizations
14121412
self.items = items
14131413
self.package_type = package_type
1414+
self.default_fragments_for_org = default_fragments_for_org
14141415
self.send_email_invite = False
14151416
self.organization_metadata = {}
14161417
self.location_metadata = {}
@@ -1440,7 +1441,7 @@ async def ListOrganizationsByUser(self, stream: Stream[ListOrganizationsByUserRe
14401441
async def GetOrganization(self, stream: Stream[GetOrganizationRequest, GetOrganizationResponse]) -> None:
14411442
request = await stream.recv_message()
14421443
assert request is not None
1443-
await stream.send_message(GetOrganizationResponse(organization=self.organizations[0]))
1444+
await stream.send_message(GetOrganizationResponse(organization=Organization(id=self.id, name=self.name, created_on=self.organizations[0].created_on, public_namespace=self.organizations[0].public_namespace, default_region=self.organizations[0].default_region, cid=self.organizations[0].cid, default_fragments=self.default_fragments_for_org)))
14441445

14451446
async def GetOrganizationNamespaceAvailability(
14461447
self, stream: Stream[GetOrganizationNamespaceAvailabilityRequest, GetOrganizationNamespaceAvailabilityResponse]
@@ -1457,7 +1458,8 @@ async def UpdateOrganization(self, stream: Stream[UpdateOrganizationRequest, Upd
14571458
self.update_cid = request.cid
14581459
self.update_name = request.name
14591460
self.update_namespace = request.public_namespace
1460-
await stream.send_message(UpdateOrganizationResponse(organization=self.organizations[0]))
1461+
self.update_default_fragments = request.default_fragments
1462+
await stream.send_message(UpdateOrganizationResponse(organization=Organization(id=self.id, name=self.name, created_on=self.organizations[0].created_on, public_namespace=self.update_namespace, default_region=self.update_region, cid=self.update_cid, default_fragments=self.update_default_fragments)))
14611463

14621464
async def DeleteOrganization(self, stream: Stream[DeleteOrganizationRequest, DeleteOrganizationResponse]) -> None:
14631465
request = await stream.recv_message()

tests/test_app_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@
208208
MODULE_FILE_INFO = ModuleFileInfo(module_id=ID, version=VERSION, platform=PLATFORM)
209209
FILE = b"file"
210210
USER_DEFINED_METADATA = {"number": 0, "string": "string"}
211+
FRAGMENT_IMPORT = FragmentImport(fragment_id=ID, version=VERSION)
212+
FRAGMENT_IMPORT_LIST = FragmentImportList(fragments=[FRAGMENT_IMPORT])
211213

212214

213215
@pytest.fixture(scope="function")
@@ -270,6 +272,7 @@ async def test_get_organization(self, service: MockApp):
270272
client = AppClient(channel, METADATA)
271273
org = await client.get_organization(org_id=ID)
272274
assert org == ORGANIZATION
275+
assert org.default_fragments == FRAGMENT_IMPORT_LIST
273276
available = await client.get_organization_namespace_availability(public_namespace=NAMESPACE)
274277
assert available == AVAILABLE
275278
assert service.namespace == NAMESPACE
@@ -297,12 +300,13 @@ async def test_list_organizations(self, service: MockApp):
297300
async def test_update_organization(self, service: MockApp):
298301
async with ChannelFor([service]) as channel:
299302
client = AppClient(channel, METADATA)
300-
org = await client.update_organization(org_id=ID, name=NAME, public_namespace=PUBLIC_NAMESPACE, region=DEFAULT_REGION, cid=CID)
303+
org = await client.update_organization(org_id=ID, name=NAME, public_namespace=PUBLIC_NAMESPACE, region=DEFAULT_REGION, cid=CID, default_fragments=FRAGMENT_IMPORT_LIST)
301304
assert org == ORGANIZATION
302305
assert service.update_region == DEFAULT_REGION
303306
assert service.update_cid == CID
304307
assert service.update_name == NAME
305308
assert service.update_namespace == PUBLIC_NAMESPACE
309+
assert service.update_default_fragments == FRAGMENT_IMPORT_LIST
306310

307311
async def test_update_organization_invite_authorizations(self, service: MockApp):
308312
async with ChannelFor([service]) as channel:

0 commit comments

Comments
 (0)