Beispiel #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'))
Beispiel #2
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')
Beispiel #3
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')
Beispiel #4
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'))