Esempio n. 1
0
    def test_json_schema__returns_dict_with_schema_urls_in_id_and_refs__when_version_from_path_is_found(
            self):
        # given
        schema_path = 'type/project/project'
        schema_json = load_json(f'{self.test_dir}/files/project.json')

        # when
        schema = MetadataSchema(schema_json, schema_path)

        # then
        expected = load_json(f'{self.test_dir}/files/project-schema.json')
        self.assertEqual(
            schema.get_json_schema(self.version_map, self.schema_base_url),
            expected)
Esempio n. 2
0
def get_block_json(filename):
    """ 得到页面文件名对应的栏切分数据 """
    filename = path.basename(filename)
    filename = path.join('block-pos',
                         *filename.split('_')[:-1],
                         re.sub(r'\..*$', '.json', filename))
    return load_json(filename, True)
Esempio n. 3
0
    def test_json_schema__raises_error__when_version_from_path_is_not_found(
            self):
        # given
        schema_path = 'type/project/project'
        schema_json = load_json(f'{self.test_dir}/files/project.json')

        # when/then
        with self.assertRaises(MetadataSchemaError):
            schema = MetadataSchema(schema_json, schema_path)
            schema.get_json_schema({'version_numbers': {}},
                                   self.schema_base_url)
Esempio n. 4
0
 def setUp(self):
     self.test_dir = os.path.dirname(os.path.realpath(__file__))
     self.version_map = load_json(f'{self.test_dir}/files/versions.json')
     self.schema_base_url = 'https://schema.humancellatlas.org/'
Esempio n. 5
0
 def get(self, name):
     cut = load_json(path.join('char-pos', *name.split('_')[:-1], name + '.json'))
     if not cut:
         return self.write(name + ' not exist')
     self.render('visualize.html', cut=cut)
Esempio n. 6
0
 def get(self):
     names = sorted([f[:-4] for f in listdir('cut-result') if f.endswith('.txt')])
     exists = [load_json(path.join('char-pos', *s.split('_')[:-1], s + '.json')) for s in names]
     items = ['<li><a href="/{0}">{0}</a>{1}</li>'.format(n, '' if e else ' ?') for n, e in zip(names, exists)]
     items = [s for s in items if '?' not in s] + [s for s in items if '?' in s]
     self.write('<ol>%s</ol>' % ''.join(items))