Example #1
0
def setup():
    global app
    here_dir = os.path.dirname(os.path.abspath(__file__))
    proj_dir = os.path.join(here_dir, 'TG2TestApp')
    
    pkg_resources.working_set.add_entry(proj_dir)

    from tg2testapp.model import DBSession, metadata, User, Group
    app = loadapp('config:development.ini', relative_to=proj_dir)
    app = TestApp(app)
    metadata.drop_all()
    metadata.create_all()

    session = DBSession
    user = User()
    user.user_name = u'asdf'
    user.email = u"*****@*****.**"
    user.password = u"asdf"
    
    session.save(user)
    
    for i in range (50):
        group = Group()
        group.group_name=unicode(i)
        session.save(group)
        user.groups.append(group)

    session.save(user)
    session.commit()
    session.flush()
Example #2
0
 def testEditRecord(self):
     from tg2testapp.model import User, Group, DBSession as session
     u = User()
     u.user_name=u'user3'
     u.password = u'asdf'
     u.email_address=u"*****@*****.**"
     session.save(u)
     group = Group()
     group.group_name=u"table_view_group"
     group.display_name=u"group"
     session.save(group)
     session.flush()
     resp = app.get('/dbmechanic/editRecord/tg_user?user_id=1')
     value =  resp.body
     assert """<td>
Example #3
0
 def testTableView(self):
     from tg2testapp.model import User, Group, DBSession as session
     u = User()
     u.user_name=u'userTableView'
     u.password = u'asdf'
     u.email_address=u"*****@*****.**"
     session.save(u)
     group = Group()
     group.group_name=u"table_view_group"
     group.display_name=u"group"
     session.save(group)
     session.flush()
     
     resp = app.get('/dbmechanic/tableView/tg_user')
     value =  resp.body
     assert """<thead>
     <tr>
         <th class="col_0">
         </th><th class="col_1">
         user_id
         </th><th class="col_2">
         user_name
         </th><th class="col_3">
         email_address
         </th><th class="col_4">
         display_name
         </th><th class="col_5">
         password
         </th><th class="col_6">
         town
         </th><th class="col_7">
         created
         </th><th class="col_8">
         tg_groups
         </th>
     </tr>
 </thead>
 <tbody>
     <tr class="even">
         <td><a href="/dbmechanic/editRecord/tg_user?user_id=1">"""
     """edit</a>|<a href="/dbmechanic/delete/tg_user?user_id=1">delete</a></td><td>1</td><td>user2</td>"""
     """<td></td><td></td><td>******</td><td>""" in value, value
Example #4
0
 def testCreateRelationships(self):
     from tg2testapp.model import User, Group, DBSession as session
     u = User()
     u.user_name=u'userCreateRel'
     u.password = u'asdf'
     u.email_address=u"*****@*****.**"
     session.save(u)
     session.commit()
     group = Group()
     group.group_name=u"create_rel_group"
     group.display_name=u"group"
     session.save(group)
     session.flush()
     u_id = str(u.user_id)
     #add group 1
     resp = app.get('/dbmechanic/edit/tg_user', params=dict(user_id=u_id, 
                                                     user_name=u'new_username',
                                                     email_address=u'*****@*****.**',
                                                     dbsprockets_id=u'editRecord__tg_user',
                                                     many_many_tg_group="1",
                                                       ))