vcttesting: add mach command to dump reviewboard account profile; r=gps
authorDan Minor <dminor@mozilla.com>
Fri, 13 Feb 2015 08:54:29 -0500
changeset 2029 8a07371eafc11e92c3f30742ce7c5f76823bde01
parent 2028 2b3ead5a152debffaffce0094a119d04e87d1063
child 2030 1927427a46a04630ed685f96980b8939f2370ca1
push id561
push userdminor@mozilla.com
push dateWed, 18 Feb 2015 15:35:46 +0000
treeherderversion-control-tools@8a07371eafc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
vcttesting: add mach command to dump reviewboard account profile; r=gps This patch adds a mach command to dump the reviewboard user profile. We modify the user profile when creating a user from bugzilla, but we don't currently have a way of quering that information after the fact when writing tests. This requires a path to the reviewboard sqlite database. I've made this an optional argument. If omitted it defaults to the path from the command's MozReview instance which makes things easier when writing tests. The make-admin command also uses sqlite directly. I've modified the path argument there to make it consistent with the new dump-account-profile command.
testing/vcttesting/reviewboard/mach_commands.py
--- a/testing/vcttesting/reviewboard/mach_commands.py
+++ b/testing/vcttesting/reviewboard/mach_commands.py
@@ -553,18 +553,39 @@ class ReviewBoardCommands(object):
             print('You must have MOZREVIEW_HOME set to restart servers')
             return 1
 
         url = self.mr.restart_reviewboard()
         print('Review Board accessible at %s' % url)
 
     @Command('make-admin', category='reviewboard',
         description='Make a user a superuser and staff user')
-    @CommandArgument('path', help='Path to Review Board install')
     @CommandArgument('email', help='Email address of user to modify')
-    def make_admin(self, path, email):
+    @CommandArgument('--path', required=False,
+                     help='Path to Review Board install')
+    def make_admin(self, email, path=None):
         import sqlite3
-        db = os.path.join(path, 'reviewboard.db')
+        db = os.path.join(path or self.mr._path, 'reviewboard.db')
         conn = sqlite3.connect(db)
         with conn:
             conn.execute('UPDATE auth_user SET is_superuser=1, is_staff=1 '
                     'WHERE email=?', (email,))
             conn.commit()
+
+    @Command('dump-account-profile', category='reviewboard',
+         description='Dump the contents of the auth_user table')
+    @CommandArgument('username', help='Username whose info the print')
+    @CommandArgument('--path', required=False,
+                     help='Path to Review Board install')
+    def dump_account_profile(self, username, path=None):
+        import sqlite3
+        db = os.path.join(path or self.mr._path, 'reviewboard.db')
+        conn = sqlite3.connect(db)
+        with conn:
+            c = conn.cursor()
+            c.execute('SELECT accounts_profile.* '
+                      'FROM auth_user, accounts_profile '
+                      'WHERE accounts_profile.user_id = auth_user.id '
+                      'AND auth_user.username = ?', (username,))
+            profile = c.fetchone()
+            if profile:
+                for i, description in enumerate(c.description):
+                    print('%s: %s' % (description[0], profile[i]))