Example #1
0
    def tearDown(self):
        del self.testapp
        from osmtm.models import DBSession
        DBSession.bind.dispose()  # dispose engine
        DBSession.remove()

        # forget any remembered authentication
        self.__forget()
Example #2
0
    def tearDown(self):
        del self.testapp
        from osmtm.models import DBSession
        DBSession.bind.dispose()  # dispose engine
        DBSession.remove()

        # forget any remembered authentication
        self.__forget()
def populate_db():
    import geoalchemy2
    import shapely

    testing.setUp()
    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    shape = shapely.geometry.Polygon([(7.23, 41.25), (7.23, 41.12),
                                      (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()
Example #4
0
def populate_db():
    import geoalchemy2
    import shapely

    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    shape = shapely.geometry.Polygon(
        [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()
def populate_db():
    import geoalchemy2
    import shapely

    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)

    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1', False)
    DBSession.add(user)

    user = User(USER2_ID, u'user2', False)
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user', True)
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    shape = shapely.geometry.Polygon(
        [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.area = area
    project.auto_fill(12)
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()
def populate_db():
    import geoalchemy2
    import shapely

    testing.setUp()
    config = ConfigParser.ConfigParser()
    config.read(local_settings_path)
    db_url = config.get('app:main', 'sqlalchemy.url')
    engine = create_engine(db_url)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
    DBSession.configure(bind=engine)

    # those users are immutables ie. they're not suppose to change during tests
    user = User(USER1_ID, u'user1')
    DBSession.add(user)

    user = User(USER2_ID, u'user2')
    DBSession.add(user)

    user = User(ADMIN_USER_ID, u'admin_user')
    user.role = User.role_admin
    DBSession.add(user)

    user = User(PROJECT_MANAGER_USER_ID, u'project_manager_user')
    user.role = User.role_project_manager
    DBSession.add(user)

    user = User(VALIDATOR_ID, u'user_validator')
    user.role = User.role_validator
    DBSession.add(user)

    user = User(EXPERIENCED_MAPPER_ID, u'user_experienced_mapper')
    user.role = User.role_experienced_mapper
    DBSession.add(user)

    license = License()
    license.name = u'LicenseBar'
    license.description = u'the_description_for_license_bar'
    license.plain_text = u'the_plain_text_for_license_bar'
    DBSession.add(license)

    label0 = Label()
    label0.name = u'bar'
    label0.color = u'#ff0000'
    DBSession.add(label0)

    label1 = Label()
    label1.name = u'dude label'
    label1.color = u'#ff0000'
    DBSession.add(label1)

    shape = shapely.geometry.Polygon(
        [(7.23, 41.25), (7.23, 41.12), (7.41, 41.20)])
    geometry = geoalchemy2.shape.from_shape(shape, 4326)
    area = Area(geometry)
    project = Project(u'test project')
    project.short_description = u'lorem ipsum description'
    project.area = area
    project.auto_fill(12)
    project.status = Project.status_published
    project.labels = [label0, label1]
    DBSession.add(project)

    transaction.commit()
    DBSession.remove()