From 2175d36db00705cbc62b9de7caf48fc6a85ef82e Mon Sep 17 00:00:00 2001
From: sidpremkumar <sid.premkumar@gmail.com>
Date: Aug 12 2019 18:20:47 +0000
Subject: Updating downstream tests and some elements in main.py to be complient with flake8


---

diff --git a/sync2jira/downstream.py b/sync2jira/downstream.py
index f517839..f3e5674 100644
--- a/sync2jira/downstream.py
+++ b/sync2jira/downstream.py
@@ -242,9 +242,9 @@ def alert_user_of_duplicate_issues(issue, final_result, results_of_query,
     admins = []
     admin_template = []
     for admin in config['sync2jira']['admins']:
-        ret = client.search_users(admin.keys()[0])
+        ret = client.search_users(list(admin.keys())[0])
         if len(ret) > 1:
-            log.warning('   Found multiple users for admin %s' % admin.keys()[0])
+            log.warning('   Found multiple users for admin %s' % list(admin.keys())[0])
             found = False
             for person in ret:
                 if person.key == issue.downstream.get('owner'):
@@ -252,9 +252,9 @@ def alert_user_of_duplicate_issues(issue, final_result, results_of_query,
                     found = True
                     break
             if not found:
-                log.warning('   Could not find JIRA user for admin %s' % admin.keys()[0])
+                log.warning('   Could not find JIRA user for admin %s' % list(admin.keys())[0])
         if not ret:
-            message = '  No admin could be found for username %s' % admin.keys()[0]
+            message = '  No admin could be found for username %s' % list(admin.keys())[0]
             log.warning(message.strip())
             raise ValueError(message)
         admins.append(ret[0].emailAddress)
@@ -497,6 +497,7 @@ def assign_user(client, issue, downstream, remove_all=False):
         return
     log.warning('Was not able to assign user %s' % issue.assignee[0]['fullname'])
 
+
 def _change_status(client, downstream, status, issue):
     """
     Change status of JIRA issue.
@@ -522,6 +523,7 @@ def _change_status(client, downstream, status, issue):
     else:
         log.warning('   Could not update JIRA %s for %s' % (status, issue.title))
 
+
 def _create_jira_issue(client, issue, config):
     """
     Create a JIRA issue and adds all relevant
@@ -587,7 +589,7 @@ def _create_jira_issue(client, issue, config):
     _attach_link(client, downstream, remote_link)
 
     default_status = issue.downstream.get('default_status', None)
-    if default_status != None:
+    if default_status is not None:
         _change_status(client, downstream, default_status, issue)
 
     # Update relevant information (i.e. tags, assignees etc.) if the
@@ -725,6 +727,7 @@ def _update_transition(client, existing, issue):
         # Find all possible transactions (i.e. change states) we could `do
         _change_status(client, existing, closed_status, issue)
 
+
 def _update_title(issue, existing):
     """
     Helper function to sync upstream/downstream title.
diff --git a/sync2jira/main.py b/sync2jira/main.py
index 6e29ce7..1801336 100644
--- a/sync2jira/main.py
+++ b/sync2jira/main.py
@@ -29,7 +29,6 @@ import traceback
 import fedmsg
 import fedmsg.config
 import jinja2
-import jira
 
 import sync2jira.upstream as u
 import sync2jira.downstream as d
@@ -197,7 +196,7 @@ def main():
             listen(config)
         except KeyboardInterrupt:
             pass
-    except:
+    except:  # noqa: E722
         report_failure(config)
         raise
 
@@ -218,7 +217,7 @@ def report_failure(config):
     # Get admin information
     admins = []
     for admin in config['sync2jira']['admins']:
-        admins.append(admin.values()[0])
+        admins.append(list(admin.values())[0])
 
     # Send mail
     send_mail(recipients=admins,
diff --git a/tests/test_downstream.py b/tests/test_downstream.py
index 7e9a928..70c742f 100644
--- a/tests/test_downstream.py
+++ b/tests/test_downstream.py
@@ -36,7 +36,7 @@ class TestDownstream(unittest.TestCase):
                 },
                 'testing': {},
                 'legacy_matching': False,
-                'admins': ['mock_admin']
+                'admins': [{'mock_admin': 'mock_email'}]
             },
         }
 

