コード例 #1
0
def requirement_setup(rc):
    rc.env = EnvironmentStub()
    
    rc.env.config.set('intertrac', 'trac.title', "Trac's Trac")
    rc.env.config.set('intertrac', 'trac.url',
                    "http://trac.edgewall.org")
    rc.env.config.set('intertrac', 't', 'trac')
    cursor = rc.env.db.cursor()


    # Must insert components so that they are found 
    # when get_wiki_syntax() in api.py is called.
    # For a better explaination, inspect _get_component_regex()
    # located in api.py
    insert_component( rc.env.db, 'component1' )
    insert_component( rc.env.db, 'long_component_1' )
    insert_component( rc.env.db, 'x' )

    from trac.db.sqlite_backend import _to_sql
    from trac.requirement.db_default import schema
    for table in schema:
        for stmt in _to_sql(table):
            cursor.execute(stmt)
    rc.env.db.commit()

    requirement = Requirement(rc.env)
    requirement['component'] = 'component1'
    requirement['fp'] = 'fp1'
    requirement['object'] = 'object1'
    requirement['creator'] = 'bob'
    requirement['description'] = 'This is the description'
    requirement.insert()
コード例 #2
0
ファイル: web_ui.py プロジェクト: cyphactor/lifecyclemanager
    def setUp(self):
        self.env = EnvironmentStub()

        self.requirement_module = RequirementModule(self.env)
        self.req = Mock(hdf=dict(), args=dict())
        self.req.href = Href("/trac")
        self.req.base_path = "http://lm"

        cursor = self.env.db.cursor()
        cursor.execute("INSERT INTO permission VALUES ('joe', 'TRAC_ADMIN')")

        from trac.db.sqlite_backend import _to_sql
        from trac.requirement.db_default import schema

        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)

        cursor.execute("INSERT INTO fp (id, name) VALUES (420, 'y')")
        cursor.execute("INSERT INTO object (id, name) VALUES (666, 'z')")
        cursor.execute("INSERT INTO requirement VALUES ('x', 420, 666, 0, 0, 'joe', 'enabled', 'foo bar')")
        cursor.execute("INSERT INTO requirement_change VALUES ('x', 420, 666, 0,'joe', 'blahd', 'foo bar', 'blahdsd')")
        cursor.execute("INSERT INTO wiki VALUES ('joe',1,122212,'author','foo','bar','comment',1)")
        cursor.execute("INSERT INTO ticket_change VALUES (1221,122212,'joe','foo','oldfoo','newfoo')")
        self.env.db.commit()

        self.req.authname = "joe"
        self.req.perm = PermissionCache(self.env, self.req.authname)
コード例 #3
0
ファイル: model.py プロジェクト: lamby/pkg-trac-spamfilter
    def setUp(self):
        self.env = EnvironmentStub()

        db = self.env.get_db_cnx()
        cursor = db.cursor()
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)
コード例 #4
0
ファイル: api.py プロジェクト: lamby/pkg-trac-spamfilter
    def setUp(self):
        self.env = EnvironmentStub(enable=[FilterSystem, DummyStrategy])

        db = self.env.get_db_cnx()
        cursor = db.cursor()
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)
コード例 #5
0
ファイル: bayes.py プロジェクト: lamby/pkg-trac-spamfilter
    def setUp(self):
        self.env = EnvironmentStub(enable=[BayesianFilterStrategy])
        self.env.config.set('spam-filter', 'bayes_karma', '10')
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)

        self.strategy = BayesianFilterStrategy(self.env)
コード例 #6
0
ファイル: test.py プロジェクト: wiraqutra/photrackjp
    def __init__(self):
        SQLiteConnection.__init__(self, ':memory:')
        cursor = self.cnx.cursor()

        from trac.db_default import schema
        from trac.db.sqlite_backend import _to_sql
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)

        self.cnx.commit()
コード例 #7
0
ファイル: test.py プロジェクト: pombredanne/trachacks
    def __init__(self):
        SQLiteConnection.__init__(self, ':memory:')
        cursor = self.cnx.cursor()

        from trac.db_default import schema
        from trac.db.sqlite_backend import _to_sql
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)

        self.cnx.commit()
コード例 #8
0
ファイル: metric.py プロジェクト: cyphactor/lifecyclemanager
    def setUp(self):
        self.env = EnvironmentStub()
        self.model = Requirement(self.env)
        self.metric = RequirementMetric(self.model)
        
        # Set midtime to one hour ago
        # This is used as a central point for mock data timestamps
        self.midtime = time.time() - (60*60)
        
        cursor = self.env.db.cursor()
        from trac.db.sqlite_backend import _to_sql
        from trac.requirement.db_default import schema
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)
        
        for component in ['comp1', 'comp2', 'comp3']:
            cursor.execute("INSERT INTO component (name) VALUES(%s)", (component,))
                    
        id = 1    
        for fp, changetime in [ ('fp1', self.midtime-2),
                                ('fp2', self.midtime-1),
                                ('fp3', self.midtime+1),
                                ('fp4', self.midtime+2)]:
            cursor.execute("INSERT INTO fp (id, name, status, time, changetime) "
                           "VALUES(%s, %s, 'enabled', %s, %s)", (id, fp, changetime, changetime))
            id += 1
        id = 1
        for object, changetime in [ ('obj1', self.midtime-2),
                                    ('obj2', self.midtime-1),
                                    ('obj3', self.midtime+1),
                                    ('obj4', self.midtime+2)]:
            cursor.execute("INSERT INTO object (id, name, status, time, changetime) "
                           "VALUES(%s, %s, 'enabled', %s, %s)", (id, object, changetime, changetime))
            id +=1

        # time/changetime are set to latest time/changetime from the corresponding fps/objs
        for component, fp, object, changetime in [  ('comp1', 1, 1, self.midtime-2),
                                                    ('comp1', 1, 2, self.midtime-1),
                                                    ('comp1', 1, 3, self.midtime+1),
                                                    ('comp1', 2, 1, self.midtime-1),
                                                    ('comp1', 3, 2, self.midtime+1),
                                                    ('comp2', 1, 3, self.midtime+1),
                                                    ('comp2', 2, 1, self.midtime-1),
                                                    ('comp3', 4, 4, self.midtime+2),
                                                    ('comp3', 3, 2, self.midtime+1),
                                                    ('comp3', 3, 1, self.midtime+1),
                                                    ('comp3', 1, 4, self.midtime+2)]:
            cursor.execute("INSERT INTO requirement (component,fp,object,status,time,changetime) "
                           "VALUES (%s,%s,%s,'enabled',%s,%s)", (component, fp, object, changetime, changetime))

        
        self.env.db.commit()
コード例 #9
0
ファイル: cache.py プロジェクト: cyphactor/lifecyclemanager
    def setUp(self):
        self.env = EnvironmentStub()
        self.requirement_system = RequirementSystem(self.env)
        
        cursor = self.env.db.cursor()

        self._insert_component('comp1')
        self._insert_component('comp2')
        self._insert_component('comp_num_3')
        self._insert_component('comp_num_4')

        from trac.db.sqlite_backend import _to_sql
        from trac.requirement.db_default import schema
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)

        self.env.db.commit()
コード例 #10
0
ファイル: test_env_helper.py プロジェクト: djangsters/agilo
            def implementation(db):
                cursor = db.cursor()
                cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
                tables = cursor.fetchall()
                for table in tables:
                    cursor.execute("DROP TABLE %s" % table)

                # part of sqlite_backend's init_db
                for table in schema:
                    for stmt in _to_sql(table):
                        cursor.execute(stmt)

                # part of reset_db
                for table, cols, vals in db_default.get_data(db):
                    cursor.executemany("INSERT INTO %s (%s) VALUES (%s)"
                                       % (table, ','.join(cols),
                                          ','.join(['%s' for c in cols])),
                        vals)
                db.commit()
コード例 #11
0
            def implementation(db):
                cursor = db.cursor()
                cursor.execute(
                    "SELECT name FROM sqlite_master WHERE type='table'")
                tables = cursor.fetchall()
                for table in tables:
                    cursor.execute("DROP TABLE %s" % table)

                # part of sqlite_backend's init_db
                for table in schema:
                    for stmt in _to_sql(table):
                        cursor.execute(stmt)

                # part of reset_db
                for table, cols, vals in db_default.get_data(db):
                    cursor.executemany(
                        "INSERT INTO %s (%s) VALUES (%s)" %
                        (table, ','.join(cols), ','.join(['%s'
                                                          for c in cols])),
                        vals)
                db.commit()
コード例 #12
0
ファイル: cache.py プロジェクト: cyphactor/lifecyclemanager
    def setUp(self):
        self.env = EnvironmentStub()
        self.cache_component = CacheComponent(self.env)

        cursor = self.env.db.cursor()
        from trac.db.sqlite_backend import _to_sql
        from trac.requirement.db_default import schema
        for table in schema:
            for stmt in _to_sql(table):
                cursor.execute(stmt)
        
        # begin with reasonably full tables of data:        
        for component, fp, object, id in [('comp1', 'fp1', 'obj1', 1),
                                          ('comp1', 'fp1', 'obj2', 1),
                                          ('comp1', 'fp1', 'obj3', 1),
                                          ('comp1', 'fp2', 'obj1', 1),
                                          ('comp1', 'fp3', 'obj2', 2),
                                          ('comp2', 'fp1', 'obj3', 2),
                                          ('comp2', 'fp2', 'obj1', 2),
                                          ('comp3', 'fp4', 'obj4', 2),
                                          ('comp3', 'fp3', 'obj2', 2),
                                          ('comp3', 'fp3', 'obj1', 3),
                                          ('comp3', 'fp1', 'obj4', 3)]:
            cursor.execute("INSERT INTO requirement_ticket_cache "
                           "(component,fp,object,ticket) VALUES "
                           "(%s,%s,%s,%s)", (component, fp, object, id))

        for comment, flag, id in [('comment1', 'comment', 1),
                                  ('comment2', 'comment', 1),
                                  ('comment3', 'comment', 3)]:
            cursor.execute("INSERT INTO ticket_change "
                           "(newvalue,field,ticket) VALUES "
                           "(%s,%s,%s)", (comment, flag, id))


        self.env.db.commit()