How to use the pybel.testing.mocks.mock_bel_resources function in pybel

To help you get started, we’ve selected a few pybel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pybel / pybel / tests / test_parse / test_parse_metadata.py View on Github external
    @mock_bel_resources
    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)
        self.parser.ensure_resources()
        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)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_fragment_specified_end_only(self, mock):
        dummy_namespace = n()
        dummy_name = n()
        node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start='*', stop=1000)])
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_fragment_specified_start_only(self, mock):
        dummy_namespace = n()
        dummy_name = n()
        node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start=5, stop='*')])
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_translocation_default(self, mock):
        """This test checks that a translocation gets in the database properly"""
        self.graph.add_increases(
            Protein(name='F2', namespace='HGNC'),
            Protein(name='EDN1', namespace='HGNC'),
            evidence='In endothelial cells, ET-1 secretion is detectable under basal conditions, whereas thrombin '
                     'induces its secretion.',
            citation='10473669',
            source_modifier=secretion(),
        )

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count(), msg='Missing one or both of the nodes.')
        self.assertEqual(1, network.edges.count(), msg='Missing the edge')
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_fragment_specified(self, mock):
        dummy_namespace = n()
        dummy_name = n()
        node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start=5, stop=8)])
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_pmod_custom_full(self, mock):
        dummy_namespace = 'HGNC'
        dummy_name = 'AKT1'
        dummy_mod_namespace = 'GO'
        dummy_mod_name = 'Protein phosphorylation'

        node_data = Protein(
            namespace=dummy_namespace,
            name=dummy_name,
            variants=[ProteinModification(name=dummy_mod_name, namespace=dummy_mod_namespace, code='Ser', position=5)]
        )
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_Hgvs(self, mock):
        node_data = Gene(namespace='HGNC', name='AKT1', variants=Hgvs('p.Phe508del'))
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_pmod_default_simple(self, mock):
        dummy_namespace = n()
        dummy_name = n()

        node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[ProteinModification('Me')])
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / test_io / test_import.py View on Github external
def setUpClass(cls):
        """Set up this class with several pre-loaded BEL graphs."""
        super().setUpClass()

        with mock_bel_resources:
            cls.thorough_graph = from_bel_script(test_bel_thorough, manager=cls.manager, disallow_nested=False)
            cls.slushy_graph = from_bel_script(
                test_bel_slushy,
                manager=cls.manager,
                disallow_unqualified_translocations=True,
                disallow_nested=True,
            )
            cls.simple_graph = from_bel_script_url(Path(test_bel_simple).as_uri(), manager=cls.manager)
            cls.isolated_graph = from_bel_script(test_bel_isolated, manager=cls.manager)
            cls.misordered_graph = from_bel_script(test_bel_misordered, manager=cls.manager, citation_clearing=False)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
    @mock_bel_resources
    def test_gmod_custom(self, mock):
        """Tests a gene modification that uses a non-default namespace"""
        dummy_namespace = 'HGNC'
        dummy_name = 'AKT1'
        dummy_mod_namespace = 'GO'
        dummy_mod_name = 'DNA Methylation'

        node_data = Gene(namespace=dummy_namespace, name=dummy_name,
                         variants=[GeneModification(name=dummy_mod_name, namespace=dummy_mod_namespace)])
        self._help_reconstitute(node_data, 2, 1)