def test_get_subgraph_by_induction(self): """Test get_subgraph_by_induction.""" graph = BELGraph() keyword, url = n(), n() graph.namespace_url[keyword] = url a, b, c, d = [protein(namespace='test', name=str(i)) for i in range(4)] graph.add_directly_increases(a, b, n(), n()) graph.add_directly_increases(b, c, n(), n()) graph.add_directly_increases(c, d, n(), n()) graph.add_increases(a, d, n(), n()) nodes = [b, c] subgraph = get_subgraph_by_induction(graph, nodes) self.assertIsInstance(subgraph, BELGraph) self.assert_all_nodes_are_base_entities(subgraph) self.assertNotEqual(0, len(subgraph.namespace_url), msg='improperly found metadata: {}'.format( subgraph.graph)) self.assertIn(keyword, subgraph.namespace_url) self.assertEqual(url, subgraph.namespace_url[keyword]) self.assertNotIn(a, subgraph) self.assertIn(b, subgraph) self.assertIn(c, subgraph) self.assertNotIn(d, subgraph)
def test_conversion(): enz = protein(name='PLCG1', namespace='HGNC') react_1 = abundance('SCHEM', '1-Phosphatidyl-D-myo-inositol 4,5-bisphosphate') p1 = abundance('SCHEM', 'Diacylglycerol') p2 = abundance('SCHEM', 'Inositol 1,4,5-trisphosphate') rxn = reaction( reactants=react_1, products=[p1, p2], ) g = BELGraph() g.add_directly_increases(enz, rxn, subject_modifier=activity(name='activity'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Conversion) assert stmt.subj.name == 'PLCG1' assert stmt.subj.activity.activity_type == 'activity' assert stmt.subj.activity.is_active is True assert len(stmt.obj_from) == 1 assert isinstance(stmt.obj_from[0], Agent) assert stmt.obj_from[0].name == '1-Phosphatidyl-D-myo-inositol ' \ '4,5-bisphosphate' assert len(stmt.obj_to) == 2 # why do these not appear in alphabetical order? # PyBEL sorts the nodes based on their BEL, and # Inositol 1,4,5-trisphosphate gets quoted. assert stmt.obj_to[0].name == 'Inositol 1,4,5-trisphosphate' assert stmt.obj_to[1].name == 'Diacylglycerol' assert len(stmt.evidence) == 1
def test_phosphorylation_two_sites(): mek = Protein(name='MAP2K1', namespace='HGNC') erk = Protein(name='MAPK1', namespace='HGNC', variants=[ pmod('Ph', position=185, code='Thr'), pmod('Ph', position=187, code='Tyr') ]) g = BELGraph() g.add_directly_increases(mek, erk, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] stmt2 = pbp.statements[1] assert stmt1.residue == 'T' assert stmt1.position == '185' assert stmt2.residue == 'Y' assert stmt2.position == '187' assert stmt1.sub.mods == [] assert stmt2.sub.mods == [] assert len(pbp.statements[0].evidence) == 1
def test_convert_increases_abundance_then_phosphorylates(self): """Test the conversion of a bel graph containing one increases abundance and one phosphorylates relationship.""" bel_graph = BELGraph() bel_graph.add_increases( oxaliplatin, reactive_o_species, evidence='10.1093/jnci/djv394', citation='26719345', ) bel_graph.add_directly_increases( reactive_o_species, p_tau, evidence=n(), citation=n(), ) re1, re2 = 1, 0 expected_reified_graph = self.help_make_simple_expected_graph( oxaliplatin, reactive_o_species, INCREASES_ABUNDANCE, re1, self.help_causal_increases) expected_reified_graph.add_node(re2, label=PHOSPHORYLATES, causal=self.help_causal_increases) expected_reified_graph.add_edge(reactive_o_species, re2, label=REIF_SUBJECT) expected_reified_graph.add_edge(p_tau, re2, label=REIF_OBJECT) reified_graph = reify_bel_graph(bel_graph) self.help_test_graphs_equal(expected_reified_graph, reified_graph)
def test_complex_stmt_with_activation(): raf = Protein(name='BRAF', namespace='HGNC') mek = Protein(name='MAP2K1', namespace='HGNC') erk = Protein(name='MAPK1', namespace='HGNC') cplx = complex_abundance([raf, mek]) g = BELGraph() g.add_directly_increases(cplx, erk, target_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] assert isinstance(stmt1, Complex) assert len(stmt1.agent_list()) == 2 assert sorted([ag.name for ag in stmt1.agent_list()]) == ['BRAF', 'MAP2K1'] assert stmt1.evidence stmt2 = pbp.statements[1] assert isinstance(stmt2, Activation) assert stmt2.subj.name == 'BRAF' assert stmt2.subj.bound_conditions[0].agent.name == 'MAP2K1' assert stmt2.obj.name == 'MAPK1' assert stmt2.obj.activity is None assert stmt2.obj_activity == 'kinase'
def test_phosphorylation_one_site_with_evidence(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC', variants=[pmod('Ph', position=185, code='Thr')]) g = BELGraph() ev_text = 'Some evidence.' ev_pmid = '123456' edge_hash = g.add_directly_increases(mek, erk, evidence=ev_text, citation=ev_pmid, annotations={"TextLocation": 'Abstract'}) pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], Phosphorylation) assert pbp.statements[0].residue == 'T' assert pbp.statements[0].position == '185' enz = pbp.statements[0].enz sub = pbp.statements[0].sub assert enz.name == 'MAP2K1' assert enz.mods == [] assert sub.name == 'MAPK1' assert sub.mods == [] # Check evidence assert len(pbp.statements[0].evidence) == 1 ev = pbp.statements[0].evidence[0] assert ev.source_api == 'bel' assert ev.source_id == edge_hash assert ev.pmid == ev_pmid assert ev.text == ev_text assert ev.annotations == {'bel': 'p(HGNC:MAP2K1) directlyIncreases ' 'p(HGNC:MAPK1, pmod(Ph, Thr, 185))'} assert ev.epistemics == {'direct': True, 'section_type': 'abstract'}
def test_convert_phosphorylates(self): """Test the conversion of a BEL statement like ``act(p(X)) -> p(Y, pmod(Ph)).""" bel_graph = BELGraph() bel_graph.add_directly_increases( cdk5, p_tau, evidence=n(), citation=n(), subject_modifier=activity('kin'), ) r_edge = 0 expected_reified_graph = self.help_make_simple_expected_graph( cdk5, p_tau, PHOSPHORYLATES, r_edge, self.help_causal_increases) reified_graph = reify_bel_graph(bel_graph) self.help_test_graphs_equal(expected_reified_graph, reified_graph)
def test_import_causal(self): """Check a directly increases.""" bel_graph = BELGraph() bel_graph.add_directly_increases(A, B, citation=TEST_CITATION, evidence=TEST_EVIDENCE) bel_graph.add_directly_decreases(B, C, citation=TEST_CITATION, evidence=TEST_EVIDENCE) bel_graph.add_negative_correlation(A, C, citation=TEST_CITATION, evidence=TEST_EVIDENCE) bel_graph.add_association(A, D, citation=TEST_CITATION, evidence=TEST_EVIDENCE) expected = NxMixedGraph.from_edges( directed=[ ('A', 'B'), ('B', 'C'), ], undirected=[ ('A', 'C'), ], ) self.nxmg_equal(expected, bel_to_nxmg(bel_graph, include_associations=False)) expected = NxMixedGraph.from_edges( directed=[ ('A', 'B'), ('B', 'C'), ], undirected=[ ('A', 'C'), ('A', 'D'), ], ) self.nxmg_equal(expected, bel_to_nxmg(bel_graph, include_associations=True))
def test_gef(): sos = protein(name='SOS1', namespace='HGNC') kras = protein(name='KRAS', namespace='HGNC') g = BELGraph() g.add_directly_increases(sos, kras, subject_modifier=activity(name='activity'), object_modifier=activity(name='gtp'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Gef) assert stmt.gef.name == 'SOS1' assert stmt.ras.name == 'KRAS' assert stmt.gef.activity.activity_type == 'activity' assert stmt.gef.activity.is_active is True assert stmt.ras.activity is None assert len(pbp.statements[0].evidence) == 1
def test_phosphorylation_two_sites(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC', variants=[pmod('Ph', position=185, code='Thr'), pmod('Ph', position=187, code='Tyr')]) g = BELGraph() g.add_directly_increases(mek, erk, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] stmt2 = pbp.statements[1] assert stmt1.residue == 'T' assert stmt1.position == '185' assert stmt2.residue == 'Y' assert stmt2.position == '187' assert stmt1.sub.mods == [] assert stmt2.sub.mods == [] assert len(pbp.statements[0].evidence) == 1
def test_gtpactivation(): kras = protein(name='KRAS', namespace='HGNC') braf = protein(name='BRAF', namespace='HGNC') g = BELGraph() g.add_directly_increases(kras, braf, subject_modifier=activity(name='gtp'), object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, GtpActivation) assert stmt.subj.name == 'KRAS' assert stmt.subj.activity.activity_type == 'gtpbound' assert stmt.subj.activity.is_active is True assert stmt.obj.name == 'BRAF' assert stmt.obj.activity is None assert stmt.obj_activity == 'kinase' assert len(stmt.evidence) == 1
def test_doi_evidence(): """Test processing edges with DOI citations.""" mek = Protein(name='MAP2K1', namespace='HGNC') erk = Protein(name='MAPK1', namespace='HGNC') g = BELGraph() g.annotation_list['TextLocation'] = {'Abstract'} ev_doi = '123456' g.add_directly_increases( mek, erk, evidence='Some evidence.', citation=('doi', ev_doi), annotations={"TextLocation": 'Abstract'}, ) pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert len(pbp.statements[0].evidence) == 1 ev = pbp.statements[0].evidence[0] assert ev.pmid is None assert 'DOI' in ev.text_refs assert ev.text_refs['DOI'] == ev_doi
def test_get_subgraph_by_induction(self): """Test get_subgraph_by_induction.""" graph = BELGraph() keyword, url = n(), n() graph.namespace_url[keyword] = url a, b, c, d = [protein(namespace='test', name=n()) for _ in range(4)] graph.add_directly_increases(a, b, n(), n()) graph.add_directly_increases(b, c, n(), n()) graph.add_directly_increases(c, d, n(), n()) graph.add_increases(a, d, n(), n()) nodes = [b.as_tuple(), c.as_tuple()] subgraph = get_subgraph_by_induction(graph, nodes) self.assertIn(keyword, subgraph.namespace_url) self.assertEqual(url, subgraph.namespace_url[keyword]) self.assert_not_in_graph(a, subgraph) self.assert_in_graph(b, subgraph) self.assert_in_graph(c, subgraph) self.assert_not_in_graph(d, subgraph)
def test_convert_two_phosphorylates(self): """Test that two phosphorylations of the same object get different reified nodes.""" bel_graph = BELGraph() for kinase in (cdk5, gsk3b): bel_graph.add_directly_increases( kinase, p_tau, evidence=n(), citation=n(), subject_modifier=activity('kin'), ) re1, re2 = 0, 1 expected_reified_graph = self.help_make_simple_expected_graph( cdk5, p_tau, PHOSPHORYLATES, re1, self.help_causal_increases) expected_reified_graph.add_node(re2, label='phosphorylates', causal=self.help_causal_increases) expected_reified_graph.add_edge(gsk3b, re2, label=REIF_SUBJECT) expected_reified_graph.add_edge(p_tau, re2, label=REIF_OBJECT) reified_graph = reify_bel_graph(bel_graph) self.help_test_graphs_equal(expected_reified_graph, reified_graph)
def test_complex_stmt_with_activation(): raf = protein(name='BRAF', namespace='HGNC') mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') cplx = complex_abundance([raf, mek]) g = BELGraph() g.add_directly_increases(cplx, erk, object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] assert isinstance(stmt1, Complex) assert len(stmt1.agent_list()) == 2 assert sorted([ag.name for ag in stmt1.agent_list()]) == ['BRAF', 'MAP2K1'] assert stmt1.evidence stmt2 = pbp.statements[1] assert isinstance(stmt2, Activation) assert stmt2.subj.name == 'BRAF' assert stmt2.subj.bound_conditions[0].agent.name == 'MAP2K1' assert stmt2.obj.name == 'MAPK1' assert stmt2.obj.activity is None assert stmt2.obj_activity == 'kinase'
kng1 = protein('HGNC', 'KNG1') kallidin = abundance('CHEBI', 'Kallidin') pla2_family = protein('SFAM', 'PLA2 Family') kng1_to_kallidin = reaction(reactants=[kng1], products=[kallidin]) example_graph.add_increases(inflammatory_process, kng1_to_kallidin, citation=c4, evidence=e4) example_graph.add_increases(kallidin, bdkrb1, citation=c4, evidence=e4, object_modifier=catalytic_activity) example_graph.add_increases(bdkrb1, pla2_family, citation=c4, evidence=e4, subject_modifier=catalytic_activity, object_modifier=catalytic_activity) c5 = '10866298' e5 = 'We found that PD180970 inhibited in vivo tyrosine phosphorylation of p210Bcr-Abl (IC50 = 170 nM) and the p210BcrAbl substrates Gab2 and CrkL (IC50 = 80 nM) in human K562 chronic myelogenous leukemic cells. In vitro, PD180970 potently inhibited autophosphorylation of p210Bcr-Abl (IC50 = 5 nM) and the kinase activity of purified recombinant Abl tyrosine kinase (IC50 = 2.2 nM).' """ SET Species = 9606 SET Citation = {"PubMed","Cancer Res 2000 Jun 15 60(12) 3127-31","10866298","","",""} kin(p(HGNC:BCR,fus(HGNC:ABL1))) directlyIncreases p(HGNC:CRKL,pmod(P,Y)) kin(p(HGNC:BCR,fus(HGNC:ABL1))) directlyIncreases p(HGNC:GAB2,pmod(P,Y)) """ bcr_abl1_fus = protein_fusion(partner_5p=protein('HGNC', 'BCR'), partner_3p=protein('HGNC', 'ABL1')) crkl_ph = protein('HGNC', 'CRKL', variants=[pmod('Ph', 'Tyr')]) gab2_ph = protein('HGNC', 'GAB2', variants=[pmod('Ph', 'Tyr')]) example_graph.add_directly_increases(bcr_abl1_fus, crkl_ph, citation=c5, evidence=e5, annotations={'Species': '9606', 'Confidence': 'High'}, subject_modifier=kinase_activity) example_graph.add_directly_increases(bcr_abl1_fus, gab2_ph, citation=c5, evidence=e5, annotations={'Species': '9606'}, subject_modifier=kinase_activity)
class TestReconstituteEdges(TemporaryCacheMixin): """This class tests that edges with varying properties can be added and extracted losslessly""" def setUp(self): """Creates a unit test with a manager and graph""" super().setUp() self.graph = BELGraph(name=n(), version=n()) @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', subject_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') #edge = network.edges.first() #self.assertEqual(2, edge.properties.count()) @mock_bel_resources def test_subject_translocation_custom_to_loc(self, mock): 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', subject_modifier=translocation( from_loc=Entity(namespace='TEST', name='A'), to_loc=Entity(namespace='GO', name='extracellular space'), )) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first() # self.assertEqual(2, edge.properties.count()) @mock_bel_resources def test_subject_activity_default(self, mock): p1_name = n() p2_name = n() self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'), Protein(name=p2_name, namespace='HGNC'), evidence=n(), citation=n(), subject_modifier=activity('kin')) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count(), msg='number of nodes') self.assertEqual(1, network.edges.count(), msg='number of edges') kin_list = self.manager.session.query(NamespaceEntry).filter( NamespaceEntry.name == 'kin').all() self.assertEqual(1, len(kin_list), msg='number of kinase NamespaceEntrys') kin = list(kin_list)[0] self.assertEqual('kin', kin.name) @mock_bel_resources def test_subject_activity_custom(self, mock): p1_name = n() p2_name = n() dummy_activity_namespace = n() dummy_activity_name = n() self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'), Protein(name=p2_name, namespace='HGNC'), evidence=n(), citation=n(), subject_modifier=activity( name=dummy_activity_name, namespace=dummy_activity_namespace)) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) kin_list = self.manager.session.query(NamespaceEntry).filter( NamespaceEntry.name == dummy_activity_name).all() self.assertEqual(1, len(kin_list)) kin = list(kin_list)[0] self.assertEqual(dummy_activity_name, kin.name) @mock_bel_resources def test_object_activity_default(self, mock): p1_name = n() p2_name = n() self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'), Protein(name=p2_name, namespace='HGNC'), evidence=n(), citation=n(), object_modifier=activity('kin')) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) kin_list = self.manager.session.query(NamespaceEntry).filter( NamespaceEntry.name == 'kin').all() self.assertEqual(1, len(kin_list)) kin = list(kin_list)[0] self.assertEqual('kin', kin.name) @mock_bel_resources def test_object_activity_custom(self, mock): p1_name = n() p2_name = n() dummy_activity_namespace = n() dummy_activity_name = n() self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'), Protein(name=p2_name, namespace='HGNC'), evidence=n(), citation=n(), object_modifier=activity( name=dummy_activity_name, namespace=dummy_activity_namespace)) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) kin_list = self.manager.session.query(NamespaceEntry).filter( NamespaceEntry.name == dummy_activity_name).all() self.assertEqual(1, len(kin_list)) kin = list(kin_list)[0] self.assertEqual(dummy_activity_name, kin.name) def test_subject_degradation(self): self.graph.add_increases( Protein(name='YFG', namespace='HGNC'), Protein(name='YFG2', namespace='HGNC'), evidence=n(), citation=n(), subject_modifier=degradation(), ) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first() # self.assertEqual(1, edge.properties.count()) def test_object_degradation(self): self.graph.add_increases( Protein(name='YFG', namespace='HGNC'), Protein(name='YFG2', namespace='HGNC'), evidence=n(), citation=n(), object_modifier=degradation(), ) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first() # self.assertEqual(1, edge.properties.count()) def test_subject_location(self): self.graph.add_increases(Protein(name='YFG', namespace='HGNC'), Protein(name='YFG2', namespace='HGNC'), evidence=n(), citation=n(), subject_modifier=location( Entity(namespace='GO', name='nucleus', identifier='GO:0005634'))) make_dummy_namespaces(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first() # self.assertEqual(1, edge.properties.count()) def test_mixed_1(self): """Test mixed having location and something else.""" self.graph.add_increases( Protein(namespace='HGNC', name='CDC42'), Protein(namespace='HGNC', name='PAK2'), evidence= """Summary: PAK proteins, a family of serine/threonine p21-activating kinases, include PAK1, PAK2, PAK3 and PAK4. PAK proteins are critical effectors that link Rho GTPases to cytoskeleton reorganization and nuclear signaling. They serve as targets for the small GTP binding proteins Cdc42 and Rac and have been implicated in a wide range of biological activities. PAK4 interacts specifically with the GTP-bound form of Cdc42Hs and weakly activates the JNK family of MAP kinases. PAK4 is a mediator of filopodia formation and may play a role in the reorganization of the actin cytoskeleton. Multiple alternatively spliced transcript variants encoding distinct isoforms have been found for this gene.""", citation={ CITATION_DB: "Online Resource", CITATION_IDENTIFIER: "PAK4 Hs ENTREZ Gene Summary" }, annotations={'Species': '9606'}, subject_modifier=activity('gtp'), object_modifier=activity('kin'), ) make_dummy_namespaces(self.manager, self.graph) make_dummy_annotations(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first() # self.assertEqual(2, edge.properties.count()) # FIXME def test_mixed_2(self): """Tests both subject and object activity with location information as well.""" self.graph.add_directly_increases( Protein(namespace='HGNC', name='HDAC4'), Protein(namespace='HGNC', name='MEF2A'), citation='10487761', evidence= """"In the nucleus, HDAC4 associates with the myocyte enhancer factor MEF2A. Binding of HDAC4 to MEF2A results in the repression of MEF2A transcriptional activation, a function that requires the deacetylase domain of HDAC4.""", annotations={'Species': '9606'}, subject_modifier=activity('cat', location=Entity(namespace='GO', name='nucleus')), object_modifier=activity('tscript', location=Entity(namespace='GO', name='nucleus'))) make_dummy_namespaces(self.manager, self.graph) make_dummy_annotations(self.manager, self.graph) network = self.manager.insert_graph(self.graph) self.assertEqual(2, network.nodes.count()) self.assertEqual(1, network.edges.count()) edge = network.edges.first()