Ejemplo n.º 1
0
    def test_triple_strings_from_file(self):
        triples = TripleStringCollection()
        self.assertIsNotNone(triples)

        count = triples.load_from_filename(
            os.path.dirname(__file__) + "/test_files/triples.txt")
        self.assertEqual(count, 3)

        self.assertTrue(triples.has_primary("key1"))
        self.assertTrue(triples.has_primary("key2"))
        self.assertTrue(triples.has_primary("key3"))

        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertTrue(triples.has_secondary("key2", "val21"))
        self.assertTrue(triples.has_secondary("key3", "val31"))

        self.assertEqual(triples.value("key1", "val11"), "val12")
        self.assertEqual(triples.value("key2", "val21"), "val22")
        self.assertEqual(triples.value("key3", "val31"), "val32:val33")
Ejemplo n.º 2
0
    def test_triple_strings_from_file(self):
        triples = TripleStringCollection ()
        self.assertIsNotNone(triples)

        count = triples.load_from_filename(os.path.dirname(__file__) +  os.sep + "test_files" + os.sep + "triples.txt")
        self.assertEqual(count, 3)

        self.assertTrue(triples.has_primary("key1"))
        self.assertTrue(triples.has_primary("key2"))
        self.assertTrue(triples.has_primary("key3"))

        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertTrue(triples.has_secondary("key2", "val21"))
        self.assertTrue(triples.has_secondary("key3", "val31"))

        self.assertEqual(triples.value("key1", "val11"), "val12")
        self.assertEqual(triples.value("key2", "val21"), "val22")
        self.assertEqual(triples.value("key3", "val31"), "val32:val33")
Ejemplo n.º 3
0
 def __init__(self, process_splits_success=True):
     TripleStringCollection.__init__(self)
     self._process_splits_success = process_splits_success
Ejemplo n.º 4
0
    def test_triple_strings_from_text(self):
        triples = TripleStringCollection ()
        self.assertIsNotNone(triples)
        self.assertEqual(".*", triples.get_split_pattern())

        count = triples.load_from_text("""
        key1:val11:val12
        key2:val21:val22
        key3:val31:val32:val33
        """)
        self.assertEqual(count, 3)

        self.assertTrue(triples.has_primary("key1"))
        self.assertTrue(triples.has_primary("key2"))
        self.assertTrue(triples.has_primary("key3"))

        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertTrue(triples.has_secondary("key2", "val21"))
        self.assertTrue(triples.has_secondary("key3", "val31"))

        self.assertEqual(triples.value("key1", "val11"), "val12")
        self.assertEqual(triples.value("key2", "val21"), "val22")
        self.assertEqual(triples.value("key3", "val31"), "val32:val33")

        self.assertIsNone(triples.value("keyX", "val31X"))
        self.assertIsNone(triples.value("key3", "val31X"))

        self.assertTrue(triples.has_primary("key1"))
        self.assertFalse(triples.has_primary("keyX"))
        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertFalse(triples.has_secondary("key1", "val1X"))
        self.assertFalse(triples.has_secondary("keyX", "val1X"))
Ejemplo n.º 5
0
 def __init__(self):
     TripleStringCollection.__init__(self)
Ejemplo n.º 6
0
 def __init__(self):
     TripleStringCollection.__init__(self)
Ejemplo n.º 7
0
 def __init__(self, process_splits_success=True):
     TripleStringCollection.__init__(self)
     self._process_splits_success = process_splits_success
Ejemplo n.º 8
0
    def test_triple_strings_from_text(self):
        triples = TripleStringCollection()
        self.assertIsNotNone(triples)
        self.assertEqual(".*", triples.get_split_pattern())

        count = triples.load_from_text("""
        key1:val11:val12
        key2:val21:val22
        key3:val31:val32:val33
        """)
        self.assertEqual(count, 3)

        self.assertTrue(triples.has_primary("key1"))
        self.assertTrue(triples.has_primary("key2"))
        self.assertTrue(triples.has_primary("key3"))

        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertTrue(triples.has_secondary("key2", "val21"))
        self.assertTrue(triples.has_secondary("key3", "val31"))

        self.assertEqual(triples.value("key1", "val11"), "val12")
        self.assertEqual(triples.value("key2", "val21"), "val22")
        self.assertEqual(triples.value("key3", "val31"), "val32:val33")

        self.assertIsNone(triples.value("keyX", "val31X"))
        self.assertIsNone(triples.value("key3", "val31X"))

        self.assertTrue(triples.has_primary("key1"))
        self.assertFalse(triples.has_primary("keyX"))
        self.assertTrue(triples.has_secondary("key1", "val11"))
        self.assertFalse(triples.has_secondary("key1", "val1X"))
        self.assertFalse(triples.has_secondary("keyX", "val1X"))