Esempio n. 1
0
 def testEdit(self):
     from tg2testapp.model import User, Group, DBSession as session
     u = User()
     u.user_name=u'userTestEdit'
     u.password = u'asdf'
     u.email_address=u"*****@*****.**"
     session.save(u)
     session.commit()
     session.flush()
     u_id = str(u.user_id)
     resp = app.get('/dbmechanic/delete/tg_user?user_id='+u_id)
Esempio n. 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>
Esempio n. 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
Esempio n. 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",
                                                       ))
Esempio n. 5
0
    def testEdit(self):
        from tg2testapp.model import User, Group, DBSession as session
        u = User()
        u.user_name=u'userTestEdit'
        u.password = u'asdf'
        u.email_address=u"*****@*****.**"
        session.save(u)
        session.commit()
        session.flush()
        u_id = str(u.user_id)
        resp = app.get('/dbmechanic/editRecord/tg_user?user_id='+u_id)
        value =  resp.body
        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'
                                                          ))
        actual =  resp.follow().namespace
        expected = {'controller': '/dbmechanic', 
                    'recordsPerPage': 25, 
                    'tableName': 'tg_user', 
                    'mainCount': 1, 
                    'page': 1}
        mainValue ={u'town': None, 
                    u'user_id': 1, 
#                           u'created': datetime.datetime(2008, 2, 23, 11, 59, 35, 144897), 
                    u'email_address': u'*****@*****.**', 
                    'tg_groups': '', 
                    u'display_name': None, 
                    u'password': '******', 
                    u'user_name': u'new_username'}
        
        for key, value in expected.iteritems():
            yield eq_, value, actual[key]
        actualRow = actual['mainValue'][0]

        for key, value in mainValue.iteritems():
            yield eq_, value, actualRow[key]