Пример #1
0
    def test_read_write_boxes(self):
        scope = Scope(package_file('model', 'tests', 'road_test.yaml'))
        db = SQLiteDB()
        scope.store_scope(db)

        s1 = Box(name="Speedy", scope=scope)
        s1.set_upper_bound('build_travel_time', 70)

        s2 = Box(name="Notable", scope=scope, parent="Speedy")
        s2.set_lower_bound('expand_capacity', 20)

        u = Boxes(s1, s2, scope=scope)

        db.write_boxes(u)

        scope2 = Scope(package_file('model', 'tests', 'road_test.yaml'))
        u2 = db.read_boxes(scope=scope2)

        assert u == u2
        assert u["Notable"].parent_box_name == u2["Notable"].parent_box_name

        s1_ = db.read_box(scope.name, "Speedy")
        s2_ = db.read_box(scope.name, "Notable")

        assert s1 == s1_
        assert s2 == s2_
        assert s1.relevant_features == s1_.relevant_features
        assert s2.relevant_features == s2_.relevant_features
Пример #2
0
    def test_read_write_box(self):
        scope = Scope(package_file('model', 'tests', 'road_test.yaml'))
        db = SQLiteDB()
        scope.store_scope(db)

        s1 = Box(name="Speedy", scope=scope)
        s1.set_upper_bound('build_travel_time', 70)
        s1.relevant_features.add('debt_type')

        s2 = Box(name="Notable", scope=scope, parent="Speedy")
        s2.set_lower_bound('expand_capacity', 20)

        db.write_box(s1)
        db.write_box(s2)

        s1_ = db.read_box(scope.name, "Speedy")
        s2_ = db.read_box(scope.name, "Notable")

        assert s1 == s1_
        assert s2 == s2_
        assert s1.thresholds == s1_.thresholds
        assert s2.thresholds == s2_.thresholds
        assert s1.relevant_features == s1_.relevant_features
        assert s2.relevant_features == s2_.relevant_features
Пример #3
0
 def test_save_scope(self):
     scp = Scope(self.scope_file)
     scp.store_scope(self.db_test)