def get_schema(self, unused_handler): reg = schema_fields.FieldRegistry(GoogleDoc.name()) reg.add_property( # To get this value, users do File > Publish to the web..., click # 'Start publishing', and then copy and paste the Document link. # Changes to the publication status of a document or to its # contents do not appear instantly. schema_fields.SchemaField( 'link', 'Document Link', 'string', optional=True, description=( 'Provide the "Document Link" from the Google Docs ' '"Publish to the web" dialog'))) reg.add_property( schema_fields.SchemaField( 'height', 'Height', 'string', i18n=False, optional=True, extra_schema_dict_values={'value': '300'}, description=( 'Height of the document, in pixels. Width will be ' 'set automatically'))) return reg
def _get_schema_field(property_type): name = property_type.name if property_type.data_type == list: # Shallow evaluation here is OK; Python DB API does not permit # array-of-array; when declaring a ListProperty, the item type # must be a Type instance (and thus cannot be a class, and thus # cannot be a Property class) item_type = schema_fields.SchemaField( name=name + ':item', label=name + ':item', optional=True, property_type=PYTHON_TYPE_TO_JSON_TYPE[property_type.item_type]) ret = schema_fields.FieldArray(name=name, label=name, description=property_type.verbose_name, item_type=item_type) else: type_name = PYTHON_TYPE_TO_JSON_TYPE.get(property_type.data_type) if not type_name: if issubclass(property_type.data_type, entities.BaseEntity): type_name = 'string' else: raise ValueError('Unsupported entity type for schema: %s' % str(property_type.data_type)) ret = schema_fields.SchemaField(name=name, label=name, property_type=type_name, description=property_type.verbose_name, optional=not property_type.required) return ret
def get_schema(self, handler): """Get the schema for specifying the question.""" question_list = [] if handler: questions = m_models.QuestionDAO.get_all() question_list = [ ( unicode(q.id), # q.id is an int; schema requires a string q.description) for q in questions ] if not question_list: return self.unavailable_schema('No questions available') reg = schema_fields.FieldRegistry('Question') reg.add_property( schema_fields.SchemaField('quid', 'Question', 'string', optional=True, i18n=False, select_data=question_list)) reg.add_property( schema_fields.SchemaField( 'weight', 'Weight', 'string', optional=True, i18n=False, extra_schema_dict_values={'value': '1'}, description='The number of points for a correct answer.')) return reg
def options_schema_provider(unused_course): extra_tab_type = schema_fields.FieldRegistry( 'Extra Tab', extra_schema_dict_values={'className': 'settings-list-item'}) extra_tab_type.add_property( schema_fields.SchemaField( LABEL_KEY, 'Title', 'string', description=messages.EXTRA_TABS_TITLE_DESCRIPTION)) extra_tab_type.add_property( schema_fields.SchemaField( POSITION_KEY, 'Tab Position', 'string', description=messages.EXTRA_TAB_POSITION_DESCRIPTION, i18n=False, optional=True, select_data=[(POS_LEFT, 'Left'), (POS_RIGHT, 'Right')])) extra_tab_type.add_property( schema_fields.SchemaField( VISIBILITY_KEY, 'Visibility', 'string', optional=True, i18n=False, description=messages.EXTRA_TABS_VISIBILITY_DESCRIPTION, select_data=[(VIS_ALL, 'Everyone'), (VIS_STUDENT, 'Registered students')])) extra_tab_type.add_property( schema_fields.SchemaField( URL_KEY, 'Tab URL', 'string', optional=True, description=messages.EXTRA_TABS_URL_DESCRIPTION, extra_schema_dict_values={ '_type': 'url', 'showMsg': True })) extra_tab_type.add_property( schema_fields.SchemaField( CONTENT_KEY, 'Tab Content', 'html', optional=True, description=messages.EXTRA_TABS_CONTENT_DESCRIPTION)) return schema_fields.FieldArray( 'course:' + EXTRA_TABS_KEY, 'Extra Tabs', item_type=extra_tab_type, description=messages.EXTRA_TABS_DESCRIPTION, extra_schema_dict_values={ 'className': 'settings-list wide', 'listAddLabel': 'Add a tab', 'listRemoveLabel': 'Delete tab' }, optional=True)
def get_schema(cls, app_context, log, source_context): ret = schema_fields.FieldRegistry('notifications') ret.add_property( schema_fields.SchemaField('timestamp_millis', 'Millisceonds Since Epoch', 'integer')) ret.add_property( schema_fields.SchemaField('status', 'Status', 'string')) ret.add_property(schema_fields.SchemaField('count', 'Count', 'integer')) return ret.get_json_schema_dict()['properties']
def test_complex_field_array(self): item_type = schema_fields.FieldRegistry(None, '') item_type.add_property(schema_fields.SchemaField('x', 'x', 'string')) item_type.add_property(schema_fields.SchemaField('y', 'y', 'datetime')) self.assertEquals( set( schema_fields.FieldArray( 'x', 'x', item_type=item_type).get_display_types()), set(['array', 'string', 'datetime', 'group']))
def get_schema(self, unused_handler): reg = schema_fields.FieldRegistry(GoogleGroup.name()) reg.add_property( schema_fields.SchemaField( 'group', 'Group Name', 'string', optional=True, description='Name of the Google Group (e.g. mapping-with-google)')) reg.add_property( schema_fields.SchemaField( 'category', 'Category Name', 'string', optional=True, description='Name of the Category (e.g. unit5-2-annotation)')) return reg
def options_schema_provider(unused_course): extra_tab_type = schema_fields.FieldRegistry( 'Extra Tab', extra_schema_dict_values={'className': 'settings-list-item'}) extra_tab_type.add_property( schema_fields.SchemaField( LABEL_KEY, 'Label', 'string', optional=True, description='The tab to be shown on the navbar.')) extra_tab_type.add_property( schema_fields.SchemaField( POSITION_KEY, 'Tab Position', 'string', description='Left and Right positions indicate on which side of the ' 'search field the tab will show in the main navigation bar.', i18n=False, optional=True, select_data=[(POS_LEFT, 'Left'), (POS_RIGHT, 'Right')])) extra_tab_type.add_property( schema_fields.SchemaField(VISIBILITY_KEY, 'Visibility', 'string', optional=True, i18n=False, select_data=[(VIS_ALL, 'Everyone'), (VIS_STUDENT, 'Registered students')])) extra_tab_type.add_property( schema_fields.SchemaField( URL_KEY, 'Tab URL', 'string', optional=True, description='If a URL is provided, the tab will link to that URL. ' 'Otherwise it will display the "tab content" in a page.')) extra_tab_type.add_property( schema_fields.SchemaField(CONTENT_KEY, 'Tab Content', 'html', optional=True)) return schema_fields.FieldArray( 'course:' + EXTRA_TABS_KEY, 'Extra tabs', item_type=extra_tab_type, description=('Extra tabs to appear on the course navbar.'), extra_schema_dict_values={ 'className': 'settings-list wide', 'listAddLabel': 'Add a tab', 'listRemoveLabel': 'Delete tab' })
def get_schema(cls): youtube_event = schema_fields.FieldRegistry('event') youtube_event.add_property( schema_fields.SchemaField( 'position', 'Position', 'integer', description='Offset from start of video, in seconds.')) youtube_event.add_property( schema_fields.SchemaField( 'action', 'Action', 'string', description='Type of event that has occurred. The types that ' 'are known are: unstarted, ended, playing, paused, buffering, ' 'and video cued. If YouTube adds more types of events than ' 'these, they will be reported as a string version of the ' 'integer event code supplied by YouTube. Please see YouTube ' 'documentation for interpretation of unknown codes.')) youtube_event.add_property( schema_fields.SchemaField( 'timestamp', 'Timestamp', 'timestamp', description='Moment when event occurred.')) youtube_interaction = schema_fields.FieldRegistry('interaction') youtube_interaction.add_property( schema_fields.SchemaField( 'video_id', 'Video ID', 'string', description='The ID of the YouTube video. E.g., Kdg2drcUjYI ') ) youtube_interaction.add_property( schema_fields.FieldArray( 'events', 'YouTube Events', item_type=youtube_event, description='A list of events describing an interaction with ' 'a video. Note that these are grouped sequentially by ' 'video ID from the raw stream. It is technically possible, ' 'though unlikely, to get confusing results if multiple ' 'videos are viewed simultaneously by one student.')) youtube_interactions = schema_fields.FieldArray( 'youtube', 'YouTube Interactions', item_type=youtube_interaction, description='A list of interactions with individual YouTube ' 'video. These are ordered by the first interaction with a ' 'given video ID, and group together multiple actions ' 'within the same interaction.') return youtube_interactions
def test_field_registry(self): registry = schema_fields.FieldRegistry(None, '') registry.add_property(schema_fields.SchemaField('x', 'x', 'string')) registry.add_property(schema_fields.SchemaField('y', 'y', 'datetime')) sub_registry = registry.add_sub_registry('sub') sub_registry.add_property( schema_fields.SchemaField('z', 'z', 'integer')) self.assertEquals(set(registry.get_display_types()), set(['string', 'datetime', 'integer', 'group']))
def get_schema(self, unused_handler): reg = schema_fields.FieldRegistry(GoogleGroup.name()) reg.add_property(schema_fields.SchemaField( 'group', 'Group Name', 'string', i18n=False, description=services.help_urls.make_learn_more_message( messages.RTE_GOOGLE_GROUP_GROUP_NAME, 'core_tags:google_group:name'))) reg.add_property(schema_fields.SchemaField( 'category', 'Category Name', 'string', optional=True, i18n=False, description=messages.RTE_GOOGLE_GROUP_CATEGORY_NAME)) return reg
def get_schema(cls, app_context, log, source_context): ret = schema_fields.FieldRegistry('enrollments') ret.add_property(schema_fields.SchemaField( 'timestamp_millis', 'Milliseconds Since Epoch', 'integer')) ret.add_property(schema_fields.SchemaField( 'add', 'Add', 'integer', description='Number of students added in this time range')) ret.add_property(schema_fields.SchemaField( 'drop', 'Drop', 'integer', description='Number of students dropped in this time range')) return ret.get_json_schema_dict()['properties']
def get_criteria_editor_schema(course): criterion_type = schema_fields.FieldRegistry( 'Criterion', extra_schema_dict_values={'className': 'settings-list-item'}) select_data = [('default', '-- Select requirement --'), ( '', '-- Custom criterion --')] for unit in course.get_assessment_list(): select_data.append((unit.unit_id, unit.title + ( ' [Peer Graded]' if course.needs_human_grader(unit) else ''))) criterion_type.add_property(schema_fields.SchemaField( 'assessment_id', 'Requirement', 'string', # The JS will only reveal the following description # for peer-graded assessments description='When specifying a peer graded assessment as criterion, ' 'the student should complete both the assessment ' 'and the minimum of peer reviews.', extra_schema_dict_values={ 'className': 'inputEx-Field assessment-dropdown' }, i18n=False, optional=True, select_data=select_data)) criterion_type.add_property(schema_fields.SchemaField( 'pass_percent', 'Passing Percentage', 'string', extra_schema_dict_values={ 'className': 'pass-percent' }, i18n=False, optional=True)) select_data = [('', '-- Select criterion method--')] + [( x, x) for x in custom_criteria.registration_table] criterion_type.add_property(schema_fields.SchemaField( 'custom_criteria', 'Custom Criterion', 'string', extra_schema_dict_values={ 'className': 'custom-criteria' }, i18n=False, optional=True, select_data=select_data)) is_peer_assessment_table = {} for unit in course.get_assessment_list(): is_peer_assessment_table[unit.unit_id] = ( True if course.needs_human_grader(unit) else False) return schema_fields.FieldArray( 'certificate_criteria', 'Certificate Criteria', item_type=criterion_type, description=services.help_urls.make_learn_more_message( messages.CERTIFICATE_CRITERIA_DESCRIPTION, 'certificate:certificate_criteria'), extra_schema_dict_values={ 'is_peer_assessment_table': is_peer_assessment_table, 'className': 'settings-list', 'listAddLabel': 'Add a criterion', 'listRemoveLabel': 'Delete criterion'}, optional=True)
def get_schema(cls, unused_app_context, unused_catch_and_log): reg.add_property( schema_fields.SchemaField('watch_time', 'Watch Time', 'dict', description='')) reg.add_property( schema_fields.SchemaField('stats_calculated', 'Stats Calculated', 'str', description='')) return reg.get_json_schema_dict()['properties']
def get_milestone_trigger_schema(cls, milestone, avail_select, trigger_cls): title = '{} Availability'.format( availability_options.option_to_title(milestone)) desc = messages.MILESTONE_TRIGGER_DESCRIPTION_FMT.format(milestone) milestone_trigger = schema_fields.FieldRegistry( title, description=services.help_urls.make_learn_more_message( desc, messages.MILESTONE_TRIGGERS_LEARN_MORE), extra_schema_dict_values={'className': trigger_cls.registry_css()}) milestone_trigger.add_property( schema_fields.SchemaField('milestone', '', 'string', i18n=False, hidden=True, extra_schema_dict_values={ 'className': trigger_cls.milestone_css() })) ms_text = availability_options.option_to_text(milestone) title = 'At {}, on this date & UTC hour:'.format(ms_text) desc = messages.MILESTONE_TRIGGER_WHEN_DESC_FMT.format( ms_text, ms_text) milestone_trigger.add_property( schema_fields.SchemaField( cls.DATETIME_FIELD, title, 'datetime', description=desc, i18n=False, optional=True, extra_schema_dict_values={'className': trigger_cls.when_css()})) title = 'Change {} availability to:'.format(milestone.split('_')[0]) desc = messages.MILESTONE_TRIGGER_AVAIL_DESC_FMT.format( ms_text, availability_options.NONE_SELECTED_TITLE, ms_text) milestone_trigger.add_property( schema_fields.SchemaField(cls.AVAILABILITY_FIELD, title, 'string', description=desc, i18n=False, optional=True, select_data=avail_select, extra_schema_dict_values={ 'className': trigger_cls.availability_css() })) return milestone_trigger
def get_schema(cls, course): course_wide_settings = schema_fields.FieldRegistry( 'Availability', description='Course Availability Settings', extra_schema_dict_values={ 'className': cls.AVAILABILITY_MANAGER_CSS }) course_wide_settings.add_property( schema_fields.SchemaField( cls.COURSE_AVAILABILITY_SETTING, 'Course Availability', 'string', description=messages.COURSE_WIDE_AVAILABILITY_DESCRIPTION, select_data=availability_options.COURSE_SELECT_DATA, i18n=False, optional=True, extra_schema_dict_values={ 'className': cls._COURSE_AVAILABILITY_CSS, 'wrapperClassName': cls._COURSE_AVAILABILITY_WRAPPER_CSS })) for milestone in constants.COURSE_MILESTONES: course_wide_settings.add_property( cls.get_milestone_array_schema( milestone, messages.MILESTONE_TRIGGER_DESC_FMT)) element_settings = cls.get_course_wide_element_schema() course_wide_settings.add_property( cls.get_element_array_schema(element_settings)) course_wide_settings.add_property( schema_fields.SchemaField( cls.WHITELIST_SETTING, 'Students Allowed to Access', 'text', description=messages.COURSE_WIDE_STUDENTS_ALLOWED_DESCRIPTION, i18n=False, optional=True, extra_schema_dict_values={ 'wrapperClassName': cls._WHITELIST_WRAPPER_CSS })) content_trigger = cls.get_content_trigger_schema( course, messages.CONTENT_TRIGGER_RESOURCE_DESCRIPTION, messages.CONTENT_TRIGGER_WHEN_DESCRIPTION, messages.CONTENT_TRIGGER_AVAIL_DESCRIPTION) course_wide_settings.add_property( cls.get_content_trigger_array_schema( triggers.ContentTrigger, content_trigger, messages.CONTENT_TRIGGERS_DESCRIPTION)) return course_wide_settings
def get_schema(cls, unused_app_context, unused_catch_and_log): reg = schema_fields.FieldRegistry( 'Units', description='Sets of lessons providing course content') reg.add_property(schema_fields.SchemaField( 'unit_id', 'Unit ID', 'integer', description='Key uniquely identifying this particular unit')) reg.add_property(schema_fields.SchemaField( 'title', 'Title', 'string', description='Human-readable title describing the unit')) reg.add_property(schema_fields.SchemaField( 'properties', 'Properties', 'object', 'Set of key/value additional properties, not further defined.')) return reg.get_json_schema_dict()['properties']
def get_schema(cls, unused_app_context, unused_catch_and_log): reg = schema_fields.FieldRegistry( 'Programming Assignments Stats', description='') reg.add_property(schema_fields.SchemaField( 'test_stats', 'Test Stats', 'str', description='')) reg.add_property(schema_fields.SchemaField( 'unit_title', 'Unit Title', 'str', description='')) reg.add_property(schema_fields.SchemaField( 'stats_calculated', 'Stats Calculated', 'str', description='')) return reg.get_json_schema_dict()['properties']
def get_course_settings_fields(): enable = schema_fields.SchemaField( 'course:invitation_email:enabled', 'Enable Invitations', 'boolean', description='Enable students to send emails inviting others to the ' 'course.', extra_schema_dict_values={ 'className': 'invitation-enable inputEx-Field inputEx-CheckBox' }, optional=True) sender_email = schema_fields.SchemaField( 'course:invitation_email:sender_email', 'Invitation Origin Email', 'string', description='The email address shown as the sender for invitation ' 'emails to this course.', extra_schema_dict_values={ 'className': 'invitation-data inputEx-Field' }, optional=True, i18n=False) subject_template = schema_fields.SchemaField( 'course:invitation_email:subject_template', 'Invitation Subject Line', 'string', description='The subject line in invitation emails to this course. ' 'Use the string {{sender_name}} to include the name of the student ' 'issuing the invitation in the subject line.', extra_schema_dict_values={ 'className': 'invitation-data inputEx-Field' }, optional=True) body_template = schema_fields.SchemaField( 'course:invitation_email:body_template', 'Invitation Body', 'text', description='The body of invitation emails to this course. ' 'Use the string {{sender_name}} to include the name of the student ' 'issuing the invitation. To avoid spamming, you should always ' 'include the string {{unsubscribe_url}} in your message to include ' 'a link which the recipient can use to unsubscribe from future ' 'invitations.', extra_schema_dict_values={ 'className': 'invitation-data inputEx-Field' }, optional=True) return (lambda c: enable, lambda c: sender_email, lambda c: subject_template, lambda c: body_template)
def test_nested_dict(self): reg = schema_fields.FieldRegistry('Test') sub_registry = schema_fields.FieldRegistry('subregistry') sub_registry.add_property(schema_fields.SchemaField( 'name', 'Name', 'string', description='user name')) sub_registry.add_property(schema_fields.SchemaField( 'city', 'City', 'string', description='city name')) reg.add_sub_registry('sub_registry', title='Sub Registry', description='a sub-registry', registry=sub_registry) complaints = transforms.validate_object_matches_json_schema( {'sub_registry': {'name': 'John Smith', 'city': 'Back East'}}, reg.get_json_schema_dict()) self.assertEqual(complaints, [])
def get_schema(self, handler): course = courses.Course(handler) lesson_id = handler.request.get('lesson_id') activity_list = [] for unit in course.get_units(): for lesson in course.get_lessons(unit.unit_id): filename = 'activity-%s.js' % lesson.lesson_id if lesson.has_activity: if lesson.activity_title: title = lesson.activity_title else: title = filename name = '%s - %s (%s) ' % (unit.title, lesson.title, title) activity_list.append((filename, name)) elif str(lesson.lesson_id) == lesson_id: name = 'Current Lesson (%s)' % filename activity_list.append((filename, name)) reg = schema_fields.FieldRegistry('Activity') reg.add_property( schema_fields.SchemaField( 'activityid', 'Activity Id', 'select', optional=True, select_data=activity_list, description=( 'The ID of the activity (e.g. activity-2.4.js). ' 'Note /assets/js/ is not required'))) return reg
def get_course_settings_fields(unused_course): return schema_fields.SchemaField( 'unit:ratings_module:enabled', 'Ratings widget', 'boolean', description='Whether to show user rating widget at the bottom of ' 'each unit and lesson.')
def get_schema(self, unused_handler): """Make schema with a list of all exercises by inspecting a zip file.""" zip_file = zipfile.ZipFile(ZIP_FILE) exercise_list = [] for name in zip_file.namelist(): if name.startswith(EXERCISE_BASE) and name != EXERCISE_BASE: exercise_list.append(name[len(EXERCISE_BASE):]) items = [] index = 1 for url in sorted(exercise_list): name = url.replace('.html', '') if _allowed(name): caption = name.replace('_', ' ') items.append((name, '#%s: %s' % (index, caption))) index += 1 reg = schema_fields.FieldRegistry('Khan Exercises') reg.add_property( schema_fields.SchemaField( 'name', 'Exercises', 'select', optional=True, select_data=items, description=('The relative URL name of the exercise.'))) return reg
def test_field_array_with_object_members(self): object_type = schema_fields.FieldRegistry('object_title') object_type.add_property( schema_fields.SchemaField('prop_name', 'prop_label', 'prop_type')) field = schema_fields.FieldArray('aName', 'aLabel', item_type=object_type) expected = """ { "items": { "type": "object", "id": "object_title", "properties": { "prop_name": {"type":"prop_type"} } }, "type":"array"} """ self.assert_json_schema_value(expected, field) expected = """ [ [["_inputex"],{"label":"aLabel"}], [["items","title"],"object_title"], [["items","properties","prop_name","_inputex"],{"label":"prop_label"}] ] """ self.assert_schema_dict_value(expected, field)
def get_schema(self, handler): api_key = None client_id = None if handler: runtime = _Runtime(handler.app_context) if not runtime.configured(): return self.unavailable_schema( services.help_urls.make_learn_more_message( messages.GOOGLE_DRIVE_UNAVAILABLE, 'core_tags:google_drive:unavailable')) api_key = runtime.get_api_key() client_id = runtime.get_client_id() reg = schema_fields.FieldRegistry(GoogleDrive.name()) reg.add_property( schema_fields.SchemaField( 'document-id', 'Document ID', 'string', description=messages.DOCUMENT_ID_DESCRIPTION, extra_schema_dict_values={ 'api-key': api_key, 'client-id': client_id, 'type-id': self.CONTENT_CHUNK_TYPE, 'xsrf-token': GoogleDriveRESTHandler.get_xsrf_token(), }, i18n=False)) return reg
def get_schema(self, handler): expected_prefix = os.path.join(appengine_config.BUNDLE_ROOT, 'assets/html') select_data = [] if handler: all_files = handler.app_context.fs.list(expected_prefix, include_inherited=True) for name in all_files: if name.startswith(expected_prefix): name = name.replace(appengine_config.BUNDLE_ROOT, '') select_data.append( (name, name.replace('/assets/html/', ''))) reg = schema_fields.FieldRegistry(Include.name()) reg.add_property( schema_fields.SchemaField( 'path', 'File Path', 'string', optional=False, select_data=select_data, description='Select a file from within assets/html. ' 'The contents of this file will be inserted verbatim ' 'at this point. Note: HTML files for inclusion may ' 'also be uploaded as assets.')) return reg
def get_schema(self, handler): api_key = None client_id = None if handler: runtime = _Runtime(handler.app_context) if not runtime.configured(): return self.unavailable_schema( 'Google Drive is not available. Please make sure the ' 'global gcb_courses_can_use_google_apis setting is True ' 'and set the Google API Key and Google Client ID in course ' 'settings in order to use this tag.') api_key = runtime.get_api_key() client_id = runtime.get_client_id() reg = schema_fields.FieldRegistry(GoogleDrive.name()) reg.add_property( schema_fields.SchemaField( 'document-id', 'Document ID', 'string', optional=True, # Validation enforced by JS code. description='The ID of the Google Drive item you want to ' 'use', i18n=False, extra_schema_dict_values={ 'api-key': api_key, 'client-id': client_id, 'type-id': self.CONTENT_CHUNK_TYPE, 'xsrf-token': GoogleDriveRESTHandler.get_xsrf_token(), })) return reg
def test_simple_field(self): field = schema_fields.SchemaField('aName', 'aLabel', 'aType') expected = '{"type":"aType"}' self.assert_json_schema_value(expected, field) expected = '[[["_inputex"], {"label": "aLabel"}]]' self.assert_schema_dict_value(expected, field) self.assertEquals('aName', field.name)
def test_single_property_with_select_data(self): reg = schema_fields.FieldRegistry('registry_name', 'registry_description') reg.add_property( schema_fields.SchemaField('field_name', 'field_label', 'string', select_data=[('a', 'A'), ('b', 'B')])) expected = """ { "properties": { "field_name": { "type": "string" } }, "type": "object", "id": "registry_name", "description": "registry_description" }""" self.assert_json_schema_value(expected, reg) expected = """ [ [["title"],"registry_name"], [["properties","field_name","_inputex"],{ "_type": "select", "choices":[ {"value": "a", "label": "A"}, {"value": "b","label": "B"}], "label":"field_label" }] ] """ self.assert_schema_dict_value(expected, reg)
def test_single_property(self): reg = schema_fields.FieldRegistry('registry_name', 'registry_description') reg.add_property( schema_fields.SchemaField('field_name', 'field_label', 'property_type', description='property_description')) expected = """ { "properties": { "field_name": { "type": "property_type", "description": "property_description" } }, "type": "object", "id": "registry_name", "description": "registry_description" }""" self.assert_json_schema_value(expected, reg) expected = """ [ [["title"], "registry_name"], [["properties","field_name","_inputex"], { "description": "property_description", "label":"field_label" }] ] """ self.assert_schema_dict_value(expected, reg)