tests/constants.py
def bel_slushy_reconstituted(self, graph: BELGraph, check_metadata: bool = True, check_warnings: bool = True):
        """Check that slushy.bel was loaded properly."""
        self.assertIsNotNone(graph)
        self.assertIsInstance(graph, BELGraph)

        if check_metadata:
            self.assertIsNotNone(graph.document)
            self.assertIsInstance(graph.document, dict)

            expected_test_slushy_metadata = {
                METADATA_NAME: "Worst. BEL Document. Ever.",
                METADATA_DESCRIPTION: "This document outlines all of the evil and awful work that is possible during BEL curation",
                METADATA_VERSION: "0.0",
                METADATA_AUTHORS: "Charles Tapley Hoyt",
                METADATA_LICENSES: "WTF License",
            }

            self.assertEqual(expected_test_slushy_metadata[METADATA_NAME], graph.name)
            self.assertEqual(expected_test_slushy_metadata[METADATA_VERSION], graph.version)
            self.assertEqual(expected_test_slushy_metadata[METADATA_DESCRIPTION], graph.description)

        if check_warnings:
            expected_warnings = [
                (0, MissingMetadataException),
                (3, VersionFormatWarning),
                (26, MissingAnnotationKeyWarning),
                (29, MissingAnnotationKeyWarning),
                (34, CitationTooShortException),
                (37, InvalidCitationType),
                (40, InvalidPubMedIdentifierWarning),
                (43, MissingCitationException),
                (48, MissingAnnotationKeyWarning),
                (51, MissingAnnotationKeyWarning),
                (54, MissingSupportWarning),
                (59, NakedNameWarning),
                (62, UndefinedNamespaceWarning),
                (65, MissingNamespaceNameWarning),
                (68, UndefinedAnnotationWarning),
                (71, MissingAnnotationKeyWarning),
                (74, IllegalAnnotationValueWarning),
                (77, MissingAnnotationRegexWarning),
                (80, MissingNamespaceRegexWarning),
                (83, MalformedTranslocationWarning),
                (86, PlaceholderAminoAcidWarning),
                (89, NestedRelationWarning),
                (92, InvalidFunctionSemantic),
                # (95, Exception),
                (98, BELSyntaxError),
            ]

            for warning_tuple in graph.warnings:
                self.assertEqual(3, len(warning_tuple), msg='Warning tuple is wrong size: {}'.format(warning_tuple))

            _sliced_warnings = [
                (w.line_number, w.__class__)
                for _, w, _ in graph.warnings
            ]
            self.assertEqual(expected_warnings, _sliced_warnings, msg='wrong warnings')

            for (el, ew), (_, exc, _) in zip(expected_warnings, graph.warnings):
                self.assertIsInstance(exc, BELParserWarning)
                self.assertIsInstance(exc.line, str)
                self.assertIsInstance(exc.line_number, int)
                self.assertIsInstance(exc.position, int)
                self.assertEqual(el, exc.line_number, msg="Expected {} on line {} but got {} on line {}: {}".format(
                    ew, el, exc.__class__, exc.line_number, exc
                ))
                self.assertIsInstance(exc, ew, msg='Line: {}'.format(el))

        for node in graph:
            self.assertIsInstance(node, BaseEntity)

        self.assertIn(akt1, graph, msg='AKT1 not in graph')
        self.assertIn(egfr, graph, msg='EGFR not in graph')

        self.assertEqual(2, graph.number_of_nodes(), msg='Wrong number of nodes retrieved from slushy.bel')
        self.assertEqual(1, graph.number_of_edges(), msg='Wrong nunber of edges retrieved from slushy.bel')

        assert_has_edge(self, akt1, egfr, graph, only=True, **{
            RELATION: INCREASES,
            CITATION: citation_1,
            EVIDENCE: evidence_1,
        })
Check that slushy.bel was loaded properly.
Check that slushy.bel was loaded properly.
Check that slushy . bel was loaded properly .
def bel_slushy_reconstituted(self, graph: BELGraph, check_metadata: bool = True, check_warnings: bool = True):
        self.assertIsNotNone(graph)
        self.assertIsInstance(graph, BELGraph)
        if check_metadata:
            self.assertIsNotNone(graph.document)
            self.assertIsInstance(graph.document, dict)
            expected_test_slushy_metadata = {
                METADATA_NAME: "Worst. BEL Document. Ever.",
                METADATA_DESCRIPTION: "This document outlines all of the evil and awful work that is possible during BEL curation",
                METADATA_VERSION: "0.0",
                METADATA_AUTHORS: "Charles Tapley Hoyt",
                METADATA_LICENSES: "WTF License",
            }
            self.assertEqual(expected_test_slushy_metadata[METADATA_NAME], graph.name)
            self.assertEqual(expected_test_slushy_metadata[METADATA_VERSION], graph.version)
            self.assertEqual(expected_test_slushy_metadata[METADATA_DESCRIPTION], graph.description)
        if check_warnings:
            expected_warnings = [
                (0, MissingMetadataException),
                (3, VersionFormatWarning),
                (26, MissingAnnotationKeyWarning),
                (29, MissingAnnotationKeyWarning),
                (34, CitationTooShortException),
                (37, InvalidCitationType),
                (40, InvalidPubMedIdentifierWarning),
                (43, MissingCitationException),
                (48, MissingAnnotationKeyWarning),
                (51, MissingAnnotationKeyWarning),
                (54, MissingSupportWarning),
                (59, NakedNameWarning),
                (62, UndefinedNamespaceWarning),
                (65, MissingNamespaceNameWarning),
                (68, UndefinedAnnotationWarning),
                (71, MissingAnnotationKeyWarning),
                (74, IllegalAnnotationValueWarning),
                (77, MissingAnnotationRegexWarning),
                (80, MissingNamespaceRegexWarning),
                (83, MalformedTranslocationWarning),
                (86, PlaceholderAminoAcidWarning),
                (89, NestedRelationWarning),
                (92, InvalidFunctionSemantic),
                (98, BELSyntaxError),
            ]
            for warning_tuple in graph.warnings:
                self.assertEqual(3, len(warning_tuple), msg='Warning tuple is wrong size: {}'.format(warning_tuple))
            _sliced_warnings = [
                (w.line_number, w.__class__)
                for _, w, _ in graph.warnings
            ]
            self.assertEqual(expected_warnings, _sliced_warnings, msg='wrong warnings')
            for (el, ew), (_, exc, _) in zip(expected_warnings, graph.warnings):
                self.assertIsInstance(exc, BELParserWarning)
                self.assertIsInstance(exc.line, str)
                self.assertIsInstance(exc.line_number, int)
                self.assertIsInstance(exc.position, int)
                self.assertEqual(el, exc.line_number, msg="Expected {} on line {} but got {} on line {}: {}".format(
                    ew, el, exc.__class__, exc.line_number, exc
                ))
                self.assertIsInstance(exc, ew, msg='Line: {}'.format(el))
        for node in graph:
            self.assertIsInstance(node, BaseEntity)
        self.assertIn(akt1, graph, msg='AKT1 not in graph')
        self.assertIn(egfr, graph, msg='EGFR not in graph')
        self.assertEqual(2, graph.number_of_nodes(), msg='Wrong number of nodes retrieved from slushy.bel')
        self.assertEqual(1, graph.number_of_edges(), msg='Wrong nunber of edges retrieved from slushy.bel')
        assert_has_edge(self, akt1, egfr, graph, only=True, **{
            RELATION: INCREASES,
            CITATION: citation_1,
            EVIDENCE: evidence_1,
        })
def bel_slushy_reconstituted ( self , graph : BELGraph , check_metadata : bool = True , check_warnings : bool = True ) : self . assertIsNotNone ( graph ) self . assertIsInstance ( graph , BELGraph ) if check_metadata : self . assertIsNotNone ( graph . document ) self . assertIsInstance ( graph . document , dict ) expected_test_slushy_metadata = { METADATA_NAME : "Worst. BEL Document. Ever." , METADATA_DESCRIPTION : "This document outlines all of the evil and awful work that is possible during BEL curation" , METADATA_VERSION : "0.0" , METADATA_AUTHORS : "Charles Tapley Hoyt" , METADATA_LICENSES : "WTF License" , } self . assertEqual ( expected_test_slushy_metadata [ METADATA_NAME ] , graph . name ) self . assertEqual ( expected_test_slushy_metadata [ METADATA_VERSION ] , graph . version ) self . assertEqual ( expected_test_slushy_metadata [ METADATA_DESCRIPTION ] , graph . description ) if check_warnings : expected_warnings = [ ( 0 , MissingMetadataException ) , ( 3 , VersionFormatWarning ) , ( 26 , MissingAnnotationKeyWarning ) , ( 29 , MissingAnnotationKeyWarning ) , ( 34 , CitationTooShortException ) , ( 37 , InvalidCitationType ) , ( 40 , InvalidPubMedIdentifierWarning ) , ( 43 , MissingCitationException ) , ( 48 , MissingAnnotationKeyWarning ) , ( 51 , MissingAnnotationKeyWarning ) , ( 54 , MissingSupportWarning ) , ( 59 , NakedNameWarning ) , ( 62 , UndefinedNamespaceWarning ) , ( 65 , MissingNamespaceNameWarning ) , ( 68 , UndefinedAnnotationWarning ) , ( 71 , MissingAnnotationKeyWarning ) , ( 74 , IllegalAnnotationValueWarning ) , ( 77 , MissingAnnotationRegexWarning ) , ( 80 , MissingNamespaceRegexWarning ) , ( 83 , MalformedTranslocationWarning ) , ( 86 , PlaceholderAminoAcidWarning ) , ( 89 , NestedRelationWarning ) , ( 92 , InvalidFunctionSemantic ) , ( 98 , BELSyntaxError ) , ] for warning_tuple in graph . warnings : self . assertEqual ( 3 , len ( warning_tuple ) , msg = 'Warning tuple is wrong size: {}' . format ( warning_tuple ) ) _sliced_warnings = [ ( w . line_number , w . __class__ ) for _ , w , _ in graph . warnings ] self . assertEqual ( expected_warnings , _sliced_warnings , msg = 'wrong warnings' ) for ( el , ew ) , ( _ , exc , _ ) in zip ( expected_warnings , graph . warnings ) : self . assertIsInstance ( exc , BELParserWarning ) self . assertIsInstance ( exc . line , str ) self . assertIsInstance ( exc . line_number , int ) self . assertIsInstance ( exc . position , int ) self . assertEqual ( el , exc . line_number , msg = "Expected {} on line {} but got {} on line {}: {}" . format ( ew , el , exc . __class__ , exc . line_number , exc ) ) self . assertIsInstance ( exc , ew , msg = 'Line: {}' . format ( el ) ) for node in graph : self . assertIsInstance ( node , BaseEntity ) self . assertIn ( akt1 , graph , msg = 'AKT1 not in graph' ) self . assertIn ( egfr , graph , msg = 'EGFR not in graph' ) self . assertEqual ( 2 , graph . number_of_nodes ( ) , msg = 'Wrong number of nodes retrieved from slushy.bel' ) self . assertEqual ( 1 , graph . number_of_edges ( ) , msg = 'Wrong nunber of edges retrieved from slushy.bel' ) assert_has_edge ( self , akt1 , egfr , graph , only = True , ** { RELATION : INCREASES , CITATION : citation_1 , EVIDENCE : evidence_1 , } )
Check that slushy.bel was loaded properly.
Check that slushy . bel was loaded properly .
"""Check that slushy.bel was loaded properly.""" # (95, Exception),
self
graph
BELGraph
check_metadata
bool
check_warnings
bool