Beispiel #1
0
    def test_power_budget_not_exceeded(self):
        demand = Demand(id=1,
                        node1=1,
                        node2=2,
                        bitrate=100,
                        paths=[(100, [1, 2]), (14, [1, 3, 2])])

        result = Result(1, demand, 0, [(4, self.transponders[0])])

        self.assertFalse(result.power_budget_exceeded(self.bands))
Beispiel #2
0
    def test_power_demand_not_fulfilled(self):
        demand = Demand(id=1,
                        node1=1,
                        node2=2,
                        bitrate=100,
                        paths=[(100, [1, 2]), (14, [1, 3, 2])])

        result = Result(1, demand, 0, [(4, self.transponders[0])])

        self.assertTrue(result.demand_not_fulfilled())
        self.assertFalse(result.is_correct(self.bands))
Beispiel #3
0
    def test_result_cost(self):
        demand = Demand(id=1,
                        node1=1,
                        node2=2,
                        bitrate=100,
                        paths=[(100, [1, 2]), (14, [1, 3, 2])])

        result = Result(1, demand, 0, [(4, self.transponders[0]),
                                       (8, self.transponders[0]),
                                       (8, self.transponders[0])])

        self.assertEqual(result.cost(), 9)
Beispiel #4
0
    def populate_db(self):

        users = []
        with open(
                os.path.join(os.path.dirname(__file__), 'resources',
                             'users.csv')) as users_csv:
            for user in users_csv:
                split_parts = user.split(',')
                users.append(
                    User(split_parts[0], split_parts[1], split_parts[2]))

        question_set = grab_questions([1, 2], True)
        db.session.add_all(question_set)
        db.session.commit()

        results = []
        with open(
                os.path.join(os.path.dirname(__file__), 'resources',
                             'results.csv')) as results_csv:
            for result in results_csv:
                split_parts = result.split(',')
                results.append(
                    Result(int(split_parts[0]), int(split_parts[1]),
                           bool(split_parts[2])))
        db.session.add_all(users)
        db.session.commit()
        db.session.add_all(results)
        db.session.commit()
Beispiel #5
0
    def test_power_demand_fulfilled(self):
        demand = Demand(id=1,
                        node1=1,
                        node2=2,
                        bitrate=100,
                        paths=[(100, [1, 2]), (14, [1, 3, 2])])

        result1 = Result(1, demand, 0, [(4, self.transponders[0]),
                                        (8, self.transponders[0]),
                                        (8, self.transponders[0])])
        result2 = Result(1, demand, 0, [(4, self.transponders[1])])

        self.assertFalse(result1.demand_not_fulfilled())
        self.assertFalse(result2.demand_not_fulfilled())