コード例 #1
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule4f(self):
        """
        4f: Wenn nicht (kein Geschwister des Typs),
            dann erstelle eine entsprechende Section, füge sie mit Property der
            Elternsection hinzu
            (TODO oder auch nur wenn nicht mehr als eine related section der gemappten Elternsection?)
        """
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        """)
        dst = parse("""
        s1[t1]
        - S2[T2]
          - P1
        """)
        self.check(src, dst)


        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t1]
        """)
        dst = parse("""
        s1[t1]
        - S2[T2]
          - P1
        s2[t1]
        """)
        self.check(src, dst)
コード例 #2
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule2(self):
        """
        2. Enthält eine Section kein Mapping und es gibt auch keines in der
           Terminologie, dann bleibt alles beim alten
        """
        src = parse("s1[t1]")
        dst = parse("s1[t1]")
        self.check(src, dst)

        odml.terminology.terminologies['map'] = parse("""
        S1[T1]
        S11[T11]
        S21[T21]
        """)
        src = parse("""
        s1[t1] mapping [T1]
        - s11[t11] mapping [T11]
        - s12[t12]
        s2[t2]
        - s21[t21] mapping [T21]
        """)
        dst = parse("""
        s1[T1]
        - s11[T11]
        - s12[t12]
        s2[t2]
        - s21[T21]
        """)
        self.check(src, dst)
コード例 #3
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_moving_section(self):
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        """)
        map = mapping.create_mapping(src)
        # now move s1 -> s2[t2]
        cmd = commands.MoveObject(obj=src['s1'], dst=src['s2'])
        cmd()

        # now src should look like this
        dst = parse("""
        s2[t2] mapping [T2]
        - s1[t1]
          - p2 mapping [T2:P1]
        """)
        self.check(src, dst, map=False)

        # and the mapping should have been updated, so that
        # it is equal to executing mapping directly
        dst = mapping.create_mapping(dst)
        self.check(map, dst, map=False)

        cmd.undo()
        # here again we lose the order
        dst = parse("""
        s2[t2] mapping [T2]
        s1[t1]
        - p2 mapping [T2:P1]
        """)
        dst = mapping.create_mapping(dst)
        self.check(map, dst, map=False)
コード例 #4
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule1_SectionNotFound(self):
     """
     a MappingError is raised when the mapping cannot be resolved
     """
     odml.terminology.terminologies['map'] = parse("S1[T1]")
     src = parse("s1[t1] mapping [T2]")
     with self.assertRaises(mapping.MappingError):
         self.check(src, None)
コード例 #5
0
ファイル: validation.py プロジェクト: asobolev/python-odml
 def test_invalid_mapped_document(self):
     # the following mapping creates an illegal document
     # in which the property P1 is found twice in the same section
     doc = samplefile.parse("""
         s1[t1]
         - p1 mapping [T1:P1]
         - P1
         """)
     odml.terminology.terminologies['map'] = samplefile.parse("""
         S1[T1]
         - P1
         """)
     res = validate(doc)
     self.assertError(res, "mapping: Object names must be unique")
コード例 #6
0
ファイル: validation.py プロジェクト: asobolev/python-odml
 def test_mapping_errors(self):
     # 1. mappings don't resolve
     doc = samplefile.parse("""s1[t1] mapping [T2]""")
     odml.terminology.terminologies['map'] = samplefile.parse("S1[T1]")
     res = validate(doc)
     self.assertError(res, "No section of type 'T2' could be found")
     
     # 2. mapped property does not resolve
     doc = samplefile.parse("""
         s1[t1]
         - p1 mapping [T1:P1]
         """)
     res = validate(doc)
     self.assertError(res, "No property named 'P1' could be found in section 'S1'")
コード例 #7
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_uniques(self):
        doc = samplefile.parse("""
            s1[t1]
            s1[t1]
            """)
        res = validate(doc)
        self.assertError(res, "name/type combination must be unique")

        doc = samplefile.parse("""
            s1[t1]
            - p1
            - p1
            """)
        res = validate(doc)
        self.assertError(res, "Object names must be unique")
コード例 #8
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_section_in_terminology(self):
        doc = samplefile.parse("""s1[T1]""")
        res = validate(doc)
        self.assertError(res, "A section should have an associated repository", filter_rep=False)

        odml.terminology.terminologies['map'] = samplefile.parse("""
        s0[t0]
        - S1[T1]
        """)
        odml.mapping.unmap_document(doc)
        doc.sections[0].repository = 'map'
        res = validate(doc)
        # TODO: mappings don't take over the repository attribute yet
        #       thus the mapped equivalent of the document would still raise the error
        self.assertEqual(self.filter_mapping_errors(res.errors), [])
コード例 #9
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_uniques(self):
        doc = samplefile.parse("""
            s1[t1]
            s1[t1]
            """)
        res = validate(doc)
        self.assertError(res, "name/type combination must be unique")

        doc = samplefile.parse("""
            s1[t1]
            - p1
            - p1
            """)
        res = validate(doc)
        self.assertError(res, "Object names must be unique")
コード例 #10
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule1(self):
     """
     1. Sections und Properties koennen Mapping Information tragen. Wenn keine
        vorhanden ist, kann diese auch in einer eventuell angegebenen Terminologie
        zu finden sein.
     1. Enthält eine Section ein Mapping, dann ändert sich der Typ der Section,
        der Name wird übernommen.
        s1[t1] mapping [T1] --> s1[T1]
     """
     odml.terminology.terminologies['map'] = parse("S1[T1]")
     odml.terminology.terminologies['term'] = parse("SX[t1] mapping [T1]")
     src = parse("s1[t1]")
     dst = parse("s1[T1]")
     src.repository = 'term'
     dst.repository = 'term'  # dst needs to be equal to src for the comparism
     self.check(src, dst)
コード例 #11
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule1(self):
     """
     1. Sections und Properties koennen Mapping Information tragen. Wenn keine
        vorhanden ist, kann diese auch in einer eventuell angegebenen Terminologie
        zu finden sein.
     1. Enthält eine Section ein Mapping, dann ändert sich der Typ der Section,
        der Name wird übernommen.
        s1[t1] mapping [T1] --> s1[T1]
     """
     odml.terminology.terminologies['map'] = parse("S1[T1]")
     odml.terminology.terminologies['term'] = parse("SX[t1] mapping [T1]")
     src = parse("s1[t1]")
     dst = parse("s1[T1]")
     src.repository = 'term'
     dst.repository = 'term' # dst needs to be equal to src for the comparism
     self.check(src, dst)
コード例 #12
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_section_in_terminology(self):
        doc = samplefile.parse("""s1[T1]""")
        res = validate(doc)
        self.assertError(res,
                         "A section should have an associated repository",
                         filter_rep=False)

        odml.terminology.terminologies['map'] = samplefile.parse("""
        s0[t0]
        - S1[T1]
        """)
        odml.mapping.unmap_document(doc)
        doc.sections[0].repository = 'map'
        res = validate(doc)
        # TODO: mappings don't take over the repository attribute yet
        #       thus the mapped equivalent of the document would still raise the error
        self.assertEqual(self.filter_mapping_errors(res.errors), [])
コード例 #13
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_editing(self):
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        """)
        map = mapping.create_mapping(src)

        src['s1'].properties['p2'].mapping = 'map#T3:P1'
        dst = parse("""
        s1[t1]
        - S3[T3]
          - P1
        s2[T2]
        """)
        self.check(map, dst, map=False)

        src['s1'].properties['p2'].mapping = 'map#T2:P1'
        dst = parse("""
        s1[t1]
        s2[T2]
        - P1
        """)
        self.check(map, dst, map=False)

        with self.assertRaises(mapping.MappingError):
            src['s2'].mapping = 'map#T3'

        src['s1'].properties['p2'].mapping = ''
        dst = parse("""
        s1[t1]
        - p2
        s2[T2]
        """)
        self.check(map, dst, map=False)

        src['s1'].mapping = 'map#T1'
        # this currently changes the order of the sections in the mapping
        # however the resulting document should still be fine
        dst = parse("""
        s2[T2]
        s1[T1]
        - p2
        """)
        self.check(map, dst, map=False)  # see above if this fails
コード例 #14
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_editing(self):
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        """)
        map = mapping.create_mapping(src)

        src['s1'].properties['p2'].mapping = 'map#T3:P1'
        dst = parse("""
        s1[t1]
        - S3[T3]
          - P1
        s2[T2]
        """)
        self.check(map, dst, map=False)

        src['s1'].properties['p2'].mapping = 'map#T2:P1'
        dst = parse("""
        s1[t1]
        s2[T2]
        - P1
        """)
        self.check(map, dst, map=False)

        with self.assertRaises(mapping.MappingError):
            src['s2'].mapping = 'map#T3'

        src['s1'].properties['p2'].mapping = ''
        dst = parse("""
        s1[t1]
        - p2
        s2[T2]
        """)
        self.check(map, dst, map=False)

        src['s1'].mapping = 'map#T1'
        # this currently changes the order of the sections in the mapping
        # however the resulting document should still be fine
        dst = parse("""
        s2[T2]
        s1[T1]
        - p2
        """)
        self.check(map, dst, map=False) # see above if this fails
コード例 #15
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4d1(self):
     """
     4d: Wenn dem nicht so ist (Elternsection != Zieltyp), dann wird zunächst
         überprüft, ob eine Kindsection der gemappten Elternsection dem
         geforderten Typ entspricht.
     4d1: Wenn ja, dann dahin (wenn eindeutig TODO) weil dies die stärkste Verwandschaftsbeziehung darstellt.
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - s2[t2] mapping [T2]
     - p2 mapping [T2:P1]
     """)
     dst = parse("""
     s1[t1]
     - s2[T2]
       - P1
     """)
     self.check(src, dst)
コード例 #16
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4d1(self):
     """
     4d: Wenn dem nicht so ist (Elternsection != Zieltyp), dann wird zunächst
         überprüft, ob eine Kindsection der gemappten Elternsection dem
         geforderten Typ entspricht.
     4d1: Wenn ja, dann dahin (wenn eindeutig TODO) weil dies die stärkste Verwandschaftsbeziehung darstellt.
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - s2[t2] mapping [T2]
     - p2 mapping [T2:P1]
     """)
     dst = parse("""
     s1[t1]
     - s2[T2]
       - P1
     """)
     self.check(src, dst)
コード例 #17
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_parse(self):
     s = """
     s1[t1] mapping [T1]
     - p1 mapping [T2:P2]
     - s2[t2] mapping [T2]
       - p3
       - p4 mapping [T3:P1]
     s2[t1]
     - s21[t2] linked to /s1/s2
     """
     doc = parse(s)
コード例 #18
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_moving_property(self):
     """
     moving a mapped property should unmap it, move it and then remap it
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     s2[t2] mapping [T2]
     """)
     map = mapping.create_mapping(src)
     # now move p2 -> s2[t2]
     cmd = commands.MoveObject(obj=src['s1'].properties['p2'], dst=src['s2'])
     cmd()
     dst = parse("""
     s1[t1]
     s2[T2]
     - P1
     """)
     self.check(map, dst, map=False)
コード例 #19
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_parse(self):
     s = """
     s1[t1] mapping [T1]
     - p1 mapping [T2:P2]
     - s2[t2] mapping [T2]
       - p3
       - p4 mapping [T3:P1]
     s2[t1]
     - s21[t2] linked to /s1/s2
     """
     doc = parse(s)
コード例 #20
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4d2(self):
     """
     4d2: Wenn nicht (mehrere Kinder des Typs), MappingError
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     - s2[t2] mapping [T2]
     - s3[T2]
     """)
     dst = parse("""
     s1[t1]
     - s2[T2]
     - s3[T2]
     S2[T2]
     - P1
     """)
     with self.assertRaises(mapping.MappingError):
         self.check(src, dst)
コード例 #21
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4c(self):
     """
     4. Wenn ein mapping vorhanden ist, dann gilt es verschiedenes zu überprüfen.
        Hier muss beachtet werden, ob es eine Abhängigkeit gibt die beachtet
        werden und erhalten werden müssen...
     4c: Ist der Zieltyp gleich dem der Elternsection, oder nicht?
         Wenn ja, dann einfach hinzufügen. (s3.p1 und s3.p2)
     """
     self.map_rule4()
     src = parse("""
     s3[t3] mapping [T3]
     - p1 mapping [T3:P2]
     - p2 mapping [T3:P3]
     """)
     dst = parse("""
     s3[T3]
     - P2
     - P3
     """)
     self.check(src, dst)
コード例 #22
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4c(self):
     """
     4. Wenn ein mapping vorhanden ist, dann gilt es verschiedenes zu überprüfen.
        Hier muss beachtet werden, ob es eine Abhängigkeit gibt die beachtet
        werden und erhalten werden müssen...
     4c: Ist der Zieltyp gleich dem der Elternsection, oder nicht?
         Wenn ja, dann einfach hinzufügen. (s3.p1 und s3.p2)
     """
     self.map_rule4()
     src = parse("""
     s3[t3] mapping [T3]
     - p1 mapping [T3:P2]
     - p2 mapping [T3:P3]
     """)
     dst = parse("""
     s3[T3]
     - P2
     - P3
     """)
     self.check(src, dst)
コード例 #23
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4d2(self):
     """
     4d2: Wenn nicht (mehrere Kinder des Typs), MappingError
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     - s2[t2] mapping [T2]
     - s3[T2]
     """)
     dst = parse("""
     s1[t1]
     - s2[T2]
     - s3[T2]
     S2[T2]
     - P1
     """)
     with self.assertRaises(mapping.MappingError):
         self.check(src, dst)
コード例 #24
0
ファイル: validation.py プロジェクト: asobolev/python-odml
 def test_property_in_terminology(self):
     doc = samplefile.parse("""
         s1[t1]
         - P1
         """)
     odml.terminology.terminologies['term'] = samplefile.parse("""
         S1[T1]
         - P1
         """)
     doc.repository = 'term'
     res = validate(doc)
     self.assertEqual(res.errors, [])
     
     doc = samplefile.parse("""
         s1[t1]
         - p1
         - P1
         """)
     doc.repository = 'term'
     res = validate(doc)
     self.assertError(res, "Property 'p1' not found in terminology")
コード例 #25
0
    def test_text_drop(self):
        sec = odml.Section(name="s1", type="t1")

        dropper = text.TextGenericDropForSectionTV(exec_func=self.execute)
        data = '<section name="s2"><type>t2</type></section>'
        print dropper.odml_tree_receive_data(self.MOVE, sec, -1, data)

        dst = samplefile.parse("""
        s1[t1]
        - s2[t2]
        """)
        self.assertEqual(sec, dst.sections[0])
コード例 #26
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4e1(self):
     """
     4d3: Wenn nicht (keine Kinder des Typs), dann gehe ich im Moment nur
          einen Schritt nach oben und überprüfe,
     4e:  ob eine Geschwistersection der gemappten Elternsection dem Property
          Zieltypen entspricht.
     4e1: Wenn ja und diese nur eine related-section des Typs der gemappten
          Elternsection hat, dort hinzufügen
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     s2[t2] mapping [T2]
     """)
     dst = parse("""
     s1[t1]
     s2[T2]
     - P1
     """)
     self.check(src, dst)
コード例 #27
0
ファイル: dnd.py プロジェクト: asobolev/python-odml
    def test_text_drop(self):
        sec = odml.Section(name="s1", type="t1")

        dropper = text.TextGenericDropForSectionTV(exec_func=self.execute)
        data = '<section name="s2"><type>t2</type></section>'
        print dropper.odml_tree_receive_data(self.MOVE, sec, -1, data)

        dst = samplefile.parse("""
        s1[t1]
        - s2[t2]
        """)
        self.assertEqual(sec, dst.sections[0])
コード例 #28
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_rule4e1(self):
     """
     4d3: Wenn nicht (keine Kinder des Typs), dann gehe ich im Moment nur
          einen Schritt nach oben und überprüfe,
     4e:  ob eine Geschwistersection der gemappten Elternsection dem Property
          Zieltypen entspricht.
     4e1: Wenn ja und diese nur eine related-section des Typs der gemappten
          Elternsection hat, dort hinzufügen
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     s2[t2] mapping [T2]
     """)
     dst = parse("""
     s1[t1]
     s2[T2]
     - P1
     """)
     self.check(src, dst)
コード例 #29
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def test_moving_property(self):
     """
     moving a mapped property should unmap it, move it and then remap it
     """
     self.map_rule4()
     src = parse("""
     s1[t1]
     - p2 mapping [T2:P1]
     s2[t2] mapping [T2]
     """)
     map = mapping.create_mapping(src)
     # now move p2 -> s2[t2]
     cmd = commands.MoveObject(obj=src['s1'].properties['p2'],
                               dst=src['s2'])
     cmd()
     dst = parse("""
     s1[t1]
     s2[T2]
     - P1
     """)
     self.check(map, dst, map=False)
コード例 #30
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_property_in_terminology(self):
        doc = samplefile.parse("""
            s1[t1]
            - P1
            """)
        odml.terminology.terminologies['term'] = samplefile.parse("""
            S1[T1]
            - P1
            """)
        doc.repository = 'term'
        res = validate(doc)
        self.assertEqual(res.errors, [])

        doc = samplefile.parse("""
            s1[t1]
            - p1
            - P1
            """)
        doc.repository = 'term'
        res = validate(doc)
        self.assertError(res, "Property 'p1' not found in terminology")
コード例 #31
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule3(self):
        """
        3: Enthält eine Property kein Mapping und es ist auch keines in der
           Terminologie vorhanden, so bleibt alles beim Alten. Die Property landet
           in der Section, in die sein Elternteil gemappt wurde.
        """
        odml.terminology.terminologies['map'] = parse("S1[T1]")
        src = parse("""
        s1[t1] mapping [T1]
        - p1
        """)
        dst = parse("""
        s1[T1]
        - p1
        """)
        self.check(src, dst)

        src = parse("""
        s1[t1]
        - p1
        """)
        dst = src.clone()
        self.check(src, dst)
コード例 #32
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def map_rule4(self):
     """
     set up the terminology for rule4 tests
     """
     odml.terminology.terminologies['map'] = parse("""
     S1[T1]
     - P2
     S2[T2]
     - P1
     S3[T3]
     - P1
     - P2
     - P3
     """)
コード例 #33
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
 def map_rule4(self):
     """
     set up the terminology for rule4 tests
     """
     odml.terminology.terminologies['map'] = parse("""
     S1[T1]
     - P2
     S2[T2]
     - P1
     S3[T3]
     - P1
     - P2
     - P3
     """)
コード例 #34
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule3(self):
        """
        3: Enthält eine Property kein Mapping und es ist auch keines in der
           Terminologie vorhanden, so bleibt alles beim Alten. Die Property landet
           in der Section, in die sein Elternteil gemappt wurde.
        """
        odml.terminology.terminologies['map'] = parse("S1[T1]")
        src = parse("""
        s1[t1] mapping [T1]
        - p1
        """)
        dst = parse("""
        s1[T1]
        - p1
        """)
        self.check(src, dst)

        src = parse("""
        s1[t1]
        - p1
        """)
        dst = src.clone()
        self.check(src, dst)
コード例 #35
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_multiple(self):
        self.map_rule4()
        src = parse("""
s1[t1] mapping [T1]
- p1 mapping [T2:P1]
- p2 mapping [T1:P2]
- p3
- p4 mapping [T3:P1]
s2[t1] mapping [T1]
- p1 mapping [T2:P1]
- p2 mapping [T1:P2]
- p3
- p4 mapping [T3:P1]
s3[t3] mapping [T3]
- p1 mapping [T3:P2]
- p2 mapping [T3:P3]
        """)
        dst = parse("""
s1[T1]
- P2
- p3
- S2[T2]
  - P1
- s3[T3] linked to /s3
  - P1
s2[T1]
- P2
- p3
- S2[T2]
  - P1
- s3[T3] linked to /s3
  - P1
s3[T3]
- P2
- P3
        """)
        self.check(src, dst)
コード例 #36
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_multiple(self):
        self.map_rule4()
        src = parse("""
s1[t1] mapping [T1]
- p1 mapping [T2:P1]
- p2 mapping [T1:P2]
- p3
- p4 mapping [T3:P1]
s2[t1] mapping [T1]
- p1 mapping [T2:P1]
- p2 mapping [T1:P2]
- p3
- p4 mapping [T3:P1]
s3[t3] mapping [T3]
- p1 mapping [T3:P2]
- p2 mapping [T3:P3]
        """)
        dst = parse("""
s1[T1]
- P2
- p3
- S2[T2]
  - P1
- s3[T3] linked to /s3
  - P1
s2[T1]
- P2
- p3
- S2[T2]
  - P1
- s3[T3] linked to /s3
  - P1
s3[T3]
- P2
- P3
        """)
        self.check(src, dst)
コード例 #37
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_property_values(self):
        # different units
        doc = samplefile.parse("""s1[t1]""")
        p = odml.Property(name="p1", value=[0, 1])
        doc["s1"].append(p)
        p.values[0].unit = "km"
        p.values[1].unit = "mV"
        res = validate(doc)
        self.assertError(res, "the same unit")

        del p.values[1]
        # missing dependency
        p.dependency = "p2"
        res = validate(doc)
        self.assertError(res, "non-existant dependency object")
コード例 #38
0
ファイル: validation.py プロジェクト: asobolev/python-odml
    def test_property_values(self):
        # different units
        doc = samplefile.parse("""s1[t1]""")
        p = odml.Property(name="p1", value=[0,1])
        doc["s1"].append(p)
        p.values[0].unit = "km"
        p.values[1].unit = "mV"
        res = validate(doc)
        self.assertError(res, "the same unit")

        del p.values[1]
        # missing dependency
        p.dependency = "p2"
        res = validate(doc)
        self.assertError(res, "non-existant dependency object")
コード例 #39
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule4e2(self):
        """
        4e2: Wenn ja und diese mehrere related-section des Typs der gemappten
             Elternsection hat, die Section mit einem link erstellen
        """
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T2] linked to /s2
          - P1
        s2[T2]
        s3[t1]
        """)
        self.check(src, dst)

        # nochmal das selbe mit entfernterer verwandtschaft
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        - s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T2] linked to /s2
          - P1
        s2[T2]
        - s3[t1]
        """)
        self.check(src, dst)

        # now test multiple links
        src = parse("""
        s1[t1]
        - p2 mapping [T3:P1]
        - p3 mapping [T3:P2]
        s2[t2] mapping [T3]
        - s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T3] linked to /s2
          - P1
          - P2
        s2[T3]
        - s3[t1]
        """)
        self.check(src, dst)
コード例 #40
0
ファイル: mapping.py プロジェクト: asobolev/python-odml
    def test_rule4e2(self):
        """
        4e2: Wenn ja und diese mehrere related-section des Typs der gemappten
             Elternsection hat, die Section mit einem link erstellen
        """
        self.map_rule4()
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T2] linked to /s2
          - P1
        s2[T2]
        s3[t1]
        """)
        self.check(src, dst)

        # nochmal das selbe mit entfernterer verwandtschaft
        src = parse("""
        s1[t1]
        - p2 mapping [T2:P1]
        s2[t2] mapping [T2]
        - s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T2] linked to /s2
          - P1
        s2[T2]
        - s3[t1]
        """)
        self.check(src, dst)

        # now test multiple links
        src = parse("""
        s1[t1]
        - p2 mapping [T3:P1]
        - p3 mapping [T3:P2]
        s2[t2] mapping [T3]
        - s3[t1]
        """)
        dst = parse("""
        s1[t1]
        - s2[T3] linked to /s2
          - P1
          - P2
        s2[T3]
        - s3[t1]
        """)
        self.check(src, dst)
コード例 #41
0
ファイル: dnd.py プロジェクト: asobolev/python-odml
    def test_ref_drop(self):
        s1 = odml.Section(name="s1", type="t1")
        doc = odml.Document()
        s2 = odml.Section(name="s2", type="t2")
        doc.append(s2)

        r = DocumentRegistry()
        id = r.add(doc)

        dropper = odmldrop.OdmlDrop(registry=r, target=targets.SectionDrop(exec_func=self.execute))
        dragger = odmldrop.OdmlDrag(inst=odml.section.Section)
        ret = dropper.odml_tree_can_drop(self.MOVE, s1, -1, None)
        self.assertTrue(ret)
        data = dragger.odml_get_data(self.MOVE, s2)
        dropper.odml_tree_receive_data(self.MOVE, s1, -1, data)

        dst = samplefile.parse("""
        s1[t1]
        - s2[t2]
        """)
        self.assertEqual(s1, dst.sections[0])
コード例 #42
0
    def test_ref_drop(self):
        s1 = odml.Section(name="s1", type="t1")
        doc = odml.Document()
        s2 = odml.Section(name="s2", type="t2")
        doc.append(s2)

        r = DocumentRegistry()
        id = r.add(doc)

        dropper = odmldrop.OdmlDrop(
            registry=r, target=targets.SectionDrop(exec_func=self.execute))
        dragger = odmldrop.OdmlDrag(inst=odml.section.Section)
        ret = dropper.odml_tree_can_drop(self.MOVE, s1, -1, None)
        self.assertTrue(ret)
        data = dragger.odml_get_data(self.MOVE, s2)
        dropper.odml_tree_receive_data(self.MOVE, s1, -1, data)

        dst = samplefile.parse("""
        s1[t1]
        - s2[t2]
        """)
        self.assertEqual(s1, dst.sections[0])
コード例 #43
0
ファイル: validation.py プロジェクト: asobolev/python-odml
 def test_section_type(self):
     doc = samplefile.parse("""s1[undefined]""")
     res = validate(doc)
     # the section type is undefined (also in the mapping)
     self.assertError(res, "Section type undefined")
コード例 #44
0
ファイル: validation.py プロジェクト: asobolev/python-odml
 def test_section_type(self):
     doc = samplefile.parse("""s1[undefined]""")
     res = validate(doc)
     # the section type is undefined (also in the mapping)
     self.assertError(res, "Section type undefined")