コード例 #1
0
    def test_namespace_name_persistience(self, mock_get):
        """Test that a namespace defined by a URL can't be overwritten by a definition by another URL."""
        s = NAMESPACE_URL_FMT.format(HGNC_KEYWORD, HGNC_URL)
        self.parser.parseString(s)
        help_check_hgnc(self, self.parser.namespace_to_term_to_encoding)

        s = NAMESPACE_URL_FMT.format(HGNC_KEYWORD, 'XXXXX')
        with self.assertRaises(RedefinedNamespaceError):
            self.parser.parseString(s)

        help_check_hgnc(self, self.parser.namespace_to_term_to_encoding)
コード例 #2
0
    def test_control_compound(self, mock_get):
        text_location = 'TextLocation'
        lines = [
            ANNOTATION_URL_FMT.format(MESH_DISEASES_KEYWORD,
                                      MESH_DISEASES_URL),
            NAMESPACE_URL_FMT.format(HGNC_KEYWORD, HGNC_URL),
            'DEFINE ANNOTATION TextLocation AS LIST {"Abstract","Results","Legend","Review"}'
        ]
        self.parser.parse_lines(lines)

        self.assertIn(MESH_DISEASES_KEYWORD, self.parser.annotation_to_term)
        self.assertIn(HGNC_KEYWORD, self.parser.namespace_to_term_to_encoding)
        self._help_test_local_annotation(text_location)
コード例 #3
0
    def test_parse_namespace_url_file(self, mock):
        """Tests parsing a namespace by file URL"""
        s = NAMESPACE_URL_FMT.format('TESTNS1', test_ns_1)
        self.parser.parseString(s)

        expected_values = {
            'TestValue1': {'O'},
            'TestValue2': {'O'},
            'TestValue3': {'O'},
            'TestValue4': {'O'},
            'TestValue5': {'O'}
        }

        self.assertIn('TESTNS1', self.parser.namespace_to_term)

        for k, values in expected_values.items():
            self.assertIn(k, self.parser.namespace_to_term['TESTNS1'])
            self.assertEqual(set(values),
                             set(self.parser.namespace_to_term['TESTNS1'][k]))
コード例 #4
0
 def test_squiggly_filepath(self):
     line = NAMESPACE_URL_FMT.format(HGNC_KEYWORD, LOCAL_TEST_PATH)
     self.parser.parseString(line)
     help_check_hgnc(self, self.parser.namespace_to_term_to_encoding)
コード例 #5
0
 def test_namespace_nocache(self):
     """Checks namespace is loaded into parser but not cached"""
     s = NAMESPACE_URL_FMT.format('TESTNS3', test_ns_nocache_path)
     self.parser.parseString(s)
     self.assertIn('TESTNS3', self.parser.namespace_to_term)
     self.assertEqual(0, len(self.manager.list_namespaces()))
コード例 #6
0
 def test_squiggly_filepath(self):
     line = NAMESPACE_URL_FMT.format(
         HGNC_KEYWORD,
         "~/dev/pybel/src/pybel/testing/resources/belns/hgnc-names.belns")
     self.parser.parseString(line)
     help_check_hgnc(self, self.parser.namespace_to_term)