Beispiel #1
0
class OrtTestCase(TestCase):
    def setUp(self):
        self.m = DiGraph()
        self.c = DiGraph()
        self.e = EndGraph()

    def test_unknown_input_does_not_pollute(self):
        self.m.add_edges_from([('A-1', 'B-1', {
            'RC': 'S',
            'PDC': 0
        }), ('B-1', 'A-1', {
            'RC': 'L',
            'PDC': 0
        }), ('A-2', 'B-1', {
            'RC': 'S',
            'PDC': 0
        }), ('B-1', 'A-2', {
            'RC': 'L',
            'PDC': 0
        }), ('A-3', 'B-2', {
            'RC': 'S',
            'PDC': 0
        }), ('B-2', 'A-3', {
            'RC': 'L',
            'PDC': 0
        }), ('A-4', 'B-2', {
            'RC': 'S',
            'PDC': 0
        }), ('B-2', 'A-4', {
            'RC': 'L',
            'PDC': 0
        })])
        self.c.add_edge('A-2',
                        'A-3',
                        EC_Source='P',
                        EC_Target='P',
                        PDC_EC_Source=0,
                        PDC_EC_Target=0,
                        PDC_Site_Source=0,
                        PDC_Site_Target=0)
        self.e.add_translated_edges(self.m, self.c, 'B', 'original')
        self.assertEqual(self.e.number_of_edges(), 1)
        self.assertEqual(self.e['1']['2']['EC_Source'], 'P')
        self.assertEqual(self.e['1']['2']['EC_Target'], 'P')
Beispiel #2
0
def test_translate_attr_modified():
    mock_conn = DiGraph()
    mock_conn.add_edge('B-1', 'B-2', Connection='Present')
    translate = EndGraph._translate_attr_modified.im_func
    # PDCs that get averaged are 3 (RCs), 6 (existent conn edge), and
    # 18 (non-existent conn edge).
    nt.assert_equal(
        translate(EndGraph(), ('A-1', ['B-1', 'B-3']), ('A-2', ['B-2']), None,
                  mock_conn), {
                      'Connection': 'Present',
                      'PDC': 6.6
                  })
Beispiel #3
0
def test_translate_attr_original():
    mock_conn = DiGraph()
    mock_conn.add_edge('B-1', 'B-2', {'EC_Source': 'N', 'EC_Target': 'Nc'})
    translate = EndGraph._translate_attr_original.im_func
    # PDCs that get averaged are 3 (RCs), 6 (existent conn edge), and
    # 18 (non-existent conn edge).
    nt.assert_equal(
        translate(EndGraph(), ('A-1', ['B-1', 'B-3']), ('A-2', ['B-2']), None,
                  mock_conn), {
                      'EC_Source': 'N',
                      'EC_Target': 'Nc',
                      'PDC': 6.6
                  })
Beispiel #4
0
class OrtTestCase(TestCase):

    def setUp(self):
        self.m = DiGraph()
        self.c = DiGraph()
        self.e = EndGraph()
        
    def test_unknown_input_does_not_pollute(self):
        self.m.add_edges_from([('A-1', 'B-1', {'RC': 'S', 'PDC': 0}),
                          ('B-1', 'A-1', {'RC': 'L', 'PDC': 0}),
                          ('A-2', 'B-1', {'RC': 'S', 'PDC': 0}),
                          ('B-1', 'A-2', {'RC': 'L', 'PDC': 0}),
                          ('A-3', 'B-2', {'RC': 'S', 'PDC': 0}),
                          ('B-2', 'A-3', {'RC': 'L', 'PDC': 0}),
                          ('A-4', 'B-2', {'RC': 'S', 'PDC': 0}),
                          ('B-2', 'A-4', {'RC': 'L', 'PDC': 0})])
        self.c.add_edge('A-2', 'A-3', EC_Source='P', EC_Target='P',
                        PDC_EC_Source=0, PDC_EC_Target=0, PDC_Site_Source=0,
                        PDC_Site_Target=0)
        self.e.add_translated_edges(self.m, self.c, 'B', 'original')
        self.assertEqual(self.e.number_of_edges(), 1)
        self.assertEqual(self.e['1']['2']['EC_Source'], 'P')
        self.assertEqual(self.e['1']['2']['EC_Target'], 'P')
Beispiel #5
0
def test_make_translation_dict():
    translate = EndGraph._make_translation_dict.im_func
    nt.assert_equal(translate(EndGraph(), None, 'A-1', 'B'), {'X': ['X']})
    nt.assert_equal(translate(EndGraph(), None, 'A-1', 'A'), {'A-1': ['A-1']})
Beispiel #6
0
 def setUp(self):
     self.m = DiGraph()
     self.c = DiGraph()
     self.e = EndGraph()
Beispiel #7
0
 def setUp(self):
     self.m = DiGraph()
     self.c = DiGraph()
     self.e = EndGraph()