Exemplo n.º 1
0
    def test_AddDivision(self):
        n = Network()
        companyid = "company"
        companyid2 = "company2"
        companyid3 = "company3"
        divisionid = "division"
        divisionid2 = "division2"
        divisionid3 = "division3"

        c = Company(companyid)
        c3 = Company(companyid3)
        d = Division(divisionid, companyid)
        d2 = Division(divisionid2, companyid2)
        n.AddCompany(c)
        n.AddCompany(c3)
        n.AddDivision(d)
        n.AddDivision(d2)
        n.AddDivisionByDef(divisionid3, companyid3)
        n.AddDivisionByDef(divisionid, companyid2)

        with self.assertRaises(Exception):
            n.AddDivisionByDef(divisionid, companyid)

        self.assertEqual(n.Companies[companyid].Divisions[divisionid].ID, divisionid)
        self.assertEqual(n.Companies[companyid2].Divisions[divisionid2].ID, divisionid2)
        self.assertEqual(n.Companies[companyid3].Divisions[divisionid3].ID, divisionid3)
        self.assertEqual(len(n.Companies[companyid2].Divisions), 2)
        self.assertEqual(n.Companies[companyid2].Divisions[divisionid].ID, divisionid)
        return
Exemplo n.º 2
0
    def test_Constructor(self):
        companyid = "company"
        c = Company(companyid, False, False)
        c2 = Company(companyid)

        self.assertEqual(c.ID, companyid)
        self.assertEqual(c.EnforceLosses, False)
        self.assertEqual(len(c.Stations), 0)
        self.assertEqual(len(c.Divisions), 0)
        self.assertEqual(c.AWR, False)

        self.assertEqual(c2.EnforceLosses, True)
        self.assertEqual(c2.AWR, True)

        return
Exemplo n.º 3
0
    def test_AddCompany(self):
        n = Network()
        companyid = "company"
        companyid2 = "company"
        companyid3 = "company3"
        c = Company(companyid)
        c2 = Company(companyid2)

        n.AddCompany(c)

        with self.assertRaises(Exception):
            n.AddCompany(c2)

        n.AddCompanyByDef(companyid3, False, False)

        self.assertEqual(n.Companies[companyid].ID, companyid)
        self.assertEqual(n.Companies[companyid3].ID,  companyid3)
        return
Exemplo n.º 4
0
    def test_AddDivision(self):
        divisionid = "divison"
        divisionid2 = "divison2"
        companyid = "company"
        c = Company(companyid)
        d = Division(divisionid, companyid)
        d2 = Division(divisionid, companyid)
        d3 = Division(divisionid2, companyid)
        c.AddDivision(d)
        with self.assertRaises(Exception):
            c.AddDivision(d2)
        c.AddDivision(d3)

        self.assertEqual(d.Company.ID, companyid)
        self.assertEqual(d.CompanyID, companyid)
        self.assertEqual(c.Divisions[d.ID].ID, divisionid)
        self.assertEqual(c.Divisions[d3.ID].ID, divisionid2)
        return
Exemplo n.º 5
0
    def test_AddStation(self):
        divisionid = "divison"
        companyid = "company"
        stationid = "station"
        stationid2 = "station2"
        c = Company(companyid)
        s = Station(stationid, companyid, divisionid)
        s2 = Station(stationid, companyid, divisionid)
        s3 = Station(stationid2, companyid, divisionid)
        c.AddStation(s)
        with self.assertRaises(Exception):
            c.AddStation(s2)
        c.AddStation(s3)

        self.assertEqual(s.Company.ID, companyid)
        self.assertEqual(s.CompanyID, companyid)
        self.assertEqual(c.Stations[s.ID].ID, stationid)
        self.assertEqual(c.Stations[s3.ID].ID, stationid2)
        return
Exemplo n.º 6
0
    def test_FindorAddCompany(self):
        n = Network()
        companyid = "company"
        companyid3 = "company3"
        c = Company(companyid)
        n.AddCompany(c)

        self.assertTrue(n.FindOrAddCompany(companyid).ID, companyid)
        self.assertTrue(n.FindOrAddCompany(companyid3).ID, companyid3)
        self.assertTrue(n.Companies[companyid3].ID, companyid3)
        return
Exemplo n.º 7
0
    def test_FindorAddDivision(self):
        n = Network()
        companyid = "company"
        companyid3 = "company3"
        divisionid = "division"
        divisionid3 = "division3"
        c = Company(companyid)
        d = Division(divisionid, companyid)
        n.AddCompany(c)
        n.AddDivision(d)

        self.assertTrue(n.FindOrAddDivision(divisionid, companyid).ID, divisionid)
        self.assertTrue(n.FindOrAddDivision(divisionid3, companyid3).ID, divisionid3)
        self.assertTrue(n.Companies[companyid3].Divisions[divisionid3].ID, divisionid3)
        return
Exemplo n.º 8
0
 def AddCompanyByDef(self, companyid, enforcelosses = True, awr = True):
     return self.AddCompany(Company(companyid, enforcelosses, awr))