def test_push_item_positive( self, is_readme_present_mock, path_exists_mock, request_api_mock, load_yaml_mock, compress_mock, getcwd_mock, rm_tarfiles_mock, check_is_author_logged_in_mock, open_mock, ): """Test for push_item positive result.""" public_id = PublicIdMock( name="some-name", author="some-author", version="{}".format(PublicIdMock.DEFAULT_VERSION), ) push_item(ContextMock(), "some-type", public_id) request_api_mock.assert_called_once_with( "POST", "/some-types/create", data={ "name": "some-name", "description": "some-description", "version": "some-version", "protocols": ["protocol_id"], }, is_auth=True, files={"file": "opened_file", "readme": "opened_file"}, )
def test_push_item_item_not_found( self, path_exists_mock, request_api_mock, load_yaml_mock, compress_mock, getcwd_mock, rm_tarfiles_mock, check_is_author_logged_in_mock, ): """Test for push_item - item not found.""" with self.assertRaises(ClickException): push_item(ContextMock(), "some-type", PublicIdMock()) request_api_mock.assert_not_called()
def test_push_item_positive_without_readme(self, is_readme_present_mock, path_exists_mock, request_api_mock, *mocks): """Test for push_item without readme positive result.""" public_id = PublicIdMock( name="some-name", author="some-author", version="{}".format(PublicIdMock.DEFAULT_VERSION), ) push_item(ContextMock(), "some-type", public_id) request_api_mock.assert_called_once_with( "POST", "/some-types/create", data={ "name": "some-name", "description": "some-description", "version": PublicIdMock.DEFAULT_VERSION, "protocols": ["protocol_id"], }, is_auth=True, files={"file": open("opened_file", "r")}, )
def skill(ctx: Context, skill_id): """Push a skill to the registry or save it in local registry.""" if ctx.config.get("local"): _save_item_locally(ctx, SKILL, skill_id) else: push_item(ctx, SKILL, skill_id)
def protocol(ctx: Context, protocol_id): """Push a protocol to the registry or save it in local registry.""" if ctx.config.get("local"): _save_item_locally(ctx, PROTOCOL, protocol_id) else: push_item(ctx, PROTOCOL, protocol_id)
def contract(ctx: Context, contract_id): """Push a contract to the registry or save it in local registry.""" if ctx.config.get("local"): _save_item_locally(ctx, CONTRACT, contract_id) else: push_item(ctx, CONTRACT, contract_id)
def connection(ctx: Context, connection_id): """Push a connection to the registry or save it in local registry.""" if ctx.config.get("local"): _save_item_locally(ctx, CONNECTION, connection_id) else: push_item(ctx, CONNECTION, connection_id)
def skill(ctx: Context, skill_id): """Push skill to Registry or save it in local packages.""" if ctx.config.get("local"): _save_item_locally(ctx, "skill", skill_id) else: push_item(ctx, "skill", skill_id)
def protocol(ctx: Context, protocol_id): """Push protocol to Registry or save it in local packages.""" if ctx.config.get("local"): _save_item_locally(ctx, "protocol", protocol_id) else: push_item(ctx, "protocol", protocol_id)
def contract(ctx: Context, contract_id): """Push connection to Registry or save it in local packages.""" if ctx.config.get("local"): _save_item_locally(ctx, "contract", contract_id) else: push_item(ctx, "contract", contract_id)
def connection(ctx: Context, connection_id): """Push connection to Registry or save it in local packages.""" if not ctx.config.get("registry"): _save_item_locally(ctx, "connection", connection_id) else: push_item(ctx, "connection", connection_id)