示例#1
0
    def test_read_project_file(self):
        with open("tests/projects.test.csv") as fin:
            projects, entity_mapping = read_project_file(fin)
            self.assertEqual(len(projects), 6)
            self.assertEqual(len(entity_mapping), 7)

            self.assertEqual(projects[0]["Coordinator"], entity_mapping["Coord one"])
            self.assertEqual(len(projects[0]["partners"]), 1)
            self.assertEqual(projects[0]["partners"][0], entity_mapping["Par 1"])

            self.assertEqual(projects[1]["Coordinator"], entity_mapping["Coord two"])
            self.assertEqual(len(projects[1]["partners"]), 1)
            self.assertEqual(projects[1]["partners"][0], entity_mapping["Part 2"])

            self.assertEqual(projects[2]["Coordinator"], entity_mapping["Coord two"])
            self.assertEqual(len(projects[2]["partners"]), 1)
            self.assertEqual(projects[2]["partners"][0], entity_mapping["Par 1"])

            self.assertEqual(projects[3]["Coordinator"], entity_mapping["Coord three"])
            self.assertEqual(len(projects[3]["partners"]), 2)
            self.assertEqual(projects[3]["partners"][0], entity_mapping["Part 2"])
            self.assertEqual(projects[3]["partners"][1], entity_mapping["Par 1"])

            self.assertEqual(projects[4]["Coordinator"], entity_mapping["Coo"])
            self.assertEqual(len(projects[4]["partners"]), 3)
            self.assertEqual(projects[4]["partners"][0], entity_mapping["Par 1"])
            self.assertEqual(projects[4]["partners"][1], entity_mapping["Par 3"])
            self.assertEqual(projects[4]["partners"][2], entity_mapping["Part 2"])

            self.assertEqual(projects[5]["Coordinator"], entity_mapping["Coord one"])
            self.assertEqual(len(projects[5]["partners"]), 1)
            self.assertEqual(projects[5]["partners"][0], entity_mapping["Par 1"])