示例#1
0
    def test_collection(self):
        collection = MapCollection()
        self.assertIsNotNone(collection)

        loader = MapLoader()
        self.assertIsNotNone(loader)

        collection._maps = loader.load_from_text("""
            KEY1:VAL1
            KEY2:VAL2
            KEY3:VAL3
            KEY4:VAL4
            KEY5:VAL5:VAL6
        """)
        self.assertIsNotNone(collection._maps)
        self.assertTrue(collection.contains('KEY1'))
        self.assertEqual(collection.map('KEY1'), 'VAL1')
        self.assertTrue(collection.contains('KEY2'))
        self.assertEqual(collection.map('KEY2'), 'VAL2')
        self.assertTrue(collection.contains('KEY3'))
        self.assertEqual(collection.map('KEY3'), 'VAL3')
        self.assertTrue(collection.contains('KEY4'))
        self.assertEqual(collection.map('KEY4'), 'VAL4')
        self.assertTrue(collection.contains('KEY5'))
        self.assertEqual(collection.map('KEY5'), 'VAL5:VAL6')
        self.assertFalse(collection.contains('KEY6'))
示例#2
0
    def test_loader_from_file(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_file_contents(os.path.dirname(__file__)+ "/test_files/maps/test_map.txt")

        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 12)
        self.assertEqual(map['ALABAMA'], 'Montgomery')
        self.assertEqual(map['COLORADO'], 'Denver')
        self.assertEqual(map['HAWAII'], 'Honolulu')
示例#3
0
    def test_loader_from_file(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_file_contents(os.path.dirname(__file__)+ "/test_files/maps/test_map.txt")

        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 12)
        self.assertEqual(map['ALABAMA'], 'MONTGOMERY')
        self.assertEqual(map['COLORADO'], 'DENVER')
        self.assertEqual(map['HAWAII'], 'HONOLULU')
示例#4
0
    def test_loader_from_file(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_file_contents(
            os.path.dirname(__file__) + "/test_files/maps/test_map.txt")

        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 12)
        self.assertEqual(map['ALABAMA'], 'MONTGOMERY')
        self.assertEqual(map['COLORADO'], 'DENVER')
        self.assertEqual(map['HAWAII'], 'HONOLULU')
示例#5
0
    def test_loader_from_file(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_file_contents(
            "/Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/src/test/mappings/test_files/maps/test_map.txt"
        )

        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 12)
        self.assertEqual(map['ALABAMA'], 'MONTGOMERY')
        self.assertEqual(map['COLORADO'], 'DENVER')
        self.assertEqual(map['HAWAII'], 'HONOLULU')
示例#6
0
    def test_loader_from_text(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_from_text("""
        KEY1:VAL1
        KEY2:VAL2
        KEY3:VAL3
        KEY4:VAL4
        """)
        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 4)
        self.assertEqual(map['KEY1'], 'VAL1')
        self.assertEqual(map['KEY2'], 'VAL2')
        self.assertEqual(map['KEY3'], 'VAL3')
        self.assertEqual(map['KEY4'], 'VAL4')
示例#7
0
    def test_loader_from_text(self):
        loader = MapLoader()
        self.assertIsNotNone(loader)

        map = loader.load_from_text("""
        KEY1:VAL1
        KEY2:VAL2
        KEY3:VAL3
        KEY4:VAL4
        """)
        self.assertIsNotNone(map)
        self.assertEqual(len(map.keys()), 4)
        self.assertEqual(map['KEY1'], 'VAL1')
        self.assertEqual(map['KEY2'], 'VAL2')
        self.assertEqual(map['KEY3'], 'VAL3')
        self.assertEqual(map['KEY4'], 'VAL4')
示例#8
0
    def test_collection(self):
        collection = MapCollection()
        self.assertIsNotNone(collection)

        loader = MapLoader()
        self.assertIsNotNone(loader)

        collection._maps = loader.load_from_text("""
            KEY1:VAL1
            KEY2:VAL2
            KEY3:VAL3
            KEY4:VAL4
        """)
        self.assertIsNotNone(collection._maps)
        self.assertTrue(collection.contains('KEY1'))
        self.assertEqual(collection.map('KEY1'), 'VAL1')
        self.assertTrue(collection.contains('KEY2'))
        self.assertEqual(collection.map('KEY2'), 'VAL2')
        self.assertTrue(collection.contains('KEY3'))
        self.assertEqual(collection.map('KEY3'), 'VAL3')
        self.assertTrue(collection.contains('KEY4'))
        self.assertEqual(collection.map('KEY4'), 'VAL4')
        self.assertFalse(collection.contains('KEY5'))