#95 Updating downstream tests and some elements in main.py to be complient with flake8
Merged 4 years ago by sidpremkumar. Opened 4 years ago by sidpremkumar.
sidpremkumar/sync-to-jira updating-downstream-tests  into  develop

file modified
+8 -5
@@ -242,9 +242,9 @@ 

      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 @@ 

                      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 @@ 

          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 @@ 

      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 @@ 

      _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 @@ 

          # 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.

file modified
+2 -3
@@ -29,7 +29,6 @@ 

  import fedmsg

  import fedmsg.config

  import jinja2

- import jira

  

  import sync2jira.upstream as u

  import sync2jira.downstream as d
@@ -197,7 +196,7 @@ 

              listen(config)

          except KeyboardInterrupt:

              pass

-     except:

+     except:  # noqa: E722

          report_failure(config)

          raise

  
@@ -218,7 +217,7 @@ 

      # 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,

file modified
+1 -1
@@ -36,7 +36,7 @@ 

                  },

                  'testing': {},

                  'legacy_matching': False,

-                 'admins': ['mock_admin']

+                 'admins': [{'mock_admin': 'mock_email'}]

              },

          }

  

Added some type assertion and modified values to work with the tox commands in place.

Pull-Request has been merged by sidpremkumar

4 years ago