From e9c44337b24c99024c4425c4a8306d5d81db3154 Mon Sep 17 00:00:00 2001
From: Tim Flink <tflink@fedoraproject.org>
Date: Nov 01 2017 16:40:42 +0000
Subject: [PATCH 1/2] adding pyo and vim swap files to gitignore


---

diff --git a/.gitignore b/.gitignore
index f9e96cd..e4f16da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *~
 __pycache__/
 #*
-*.pyc
\ No newline at end of file
+*.py[co]
+.*.swp

From 388623f921206385746ab1702cffd98454a2db82 Mon Sep 17 00:00:00 2001
From: Tim Flink <tflink@fedoraproject.org>
Date: Nov 01 2017 16:41:43 +0000
Subject: [PATCH 2/2] adding tox.ini for flake8 settings, style updates for python code


---

diff --git a/api_server.py b/api_server.py
index 5781439..5b3c4d7 100644
--- a/api_server.py
+++ b/api_server.py
@@ -5,7 +5,7 @@
 # Author: Mike Ruckman <roshi@fedoraproject.org>
 
 import hug
-from sqlalchemy import create_engine, func
+from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker
 from marshmallow_sqlalchemy import ModelSchema
 
@@ -18,13 +18,16 @@ Session.configure(bind=engine)
 
 session = Session()
 
+
 class ProjectSchema(ModelSchema):
     '''Make it so we can serialize our objects to json.'''
     class Meta:
         model = Project
 
+
 schema = ProjectSchema()
 
+
 @hug.directive()
 def cors(support="*", response=None, **kwargs):
     '''Set the 'Access-Control-Allow-Origin' header for all requests,
@@ -32,21 +35,25 @@ def cors(support="*", response=None, **kwargs):
     '''
     response and response.set_header('Access-Control-Allow-Origin', '*')
 
+
 @hug.get(accept=('GET', 'OPTIONS'))
 def all(hug_cors):
     '''Return a list of all projects in the database.'''
     return [schema.dump(x).data for x in session.query(Project).all()]
 
+
 @hug.get()
 def migrated(hug_cors):
     '''Return a list of all migrated projects.'''
     migrated = [schema.dump(x).data for x in session.query(Project).filter_by(status=u'MIGRATED').all()]
 
+
 @hug.get()
 def working(hug_cors):
     '''Return a list of all working projects.'''
     return [schema.dump(x).data for x in session.query(Project).filter_by(status=u'WORKING').all()]
 
+
 @hug.get()
 def counts(hug_cors):
     '''Return the counts of each status.'''
diff --git a/server.py b/server.py
index a8cbfa6..bbe1d5d 100644
--- a/server.py
+++ b/server.py
@@ -19,6 +19,7 @@ from sqlalchemy.ext.declarative import declarative_base
 
 Base = declarative_base()
 
+
 class Project(Base):
 
     __tablename__ = 'projects'
@@ -28,19 +29,19 @@ class Project(Base):
     status = Column(String)
     pagure_link = Column(String)
     contact = Column(String)
-    
+
     def get_project_issues(self):
         '''Update self.status to WORKING if there are issues attached to it.'''
 
         issues_url = config.API_URL + "{}/issues".format(self.name)
         issues = requests.get(issues_url)
-    
+
         if issues.status_code == 404:
             logging.debug("Issues not found for: {}".format(self.name))
             return None
-    
+
         issues = json.loads(issues.text)
-    
+
         if issues['total_issues'] is not 0:
             self.update_status("WORKING")
         else:
@@ -49,6 +50,7 @@ class Project(Base):
     def update_status(self, status):
         self.status = status
 
+
 def get_session():
     '''Return a session object to interact with the database.'''
 
@@ -56,19 +58,20 @@ def get_session():
     Session.configure(bind=engine)
 
     return Session()
-    
+
+
 def setup_database():
     '''Do the initial setup of the database. This should be run once.'''
     Base.metadata.create_all(engine)
     session = get_session()
-    
+
     logging.info("Reading in the package list...\n")
     with open('UpstreamFirstPackageList.csv', 'r') as rawlist:
         packages = rawlist.readlines()
 
         # Remove the header row
         packages = packages[1:]
-        
+
     logging.info("There are {} packages initially\n".format(len(packages)))
     for package in clean_list(packages):
         package = hawkey.split_nevra(package)
@@ -80,17 +83,19 @@ def setup_database():
 
     # Now run the main() method to update with info from the forge.
     main()
-    
+
+
 def clean_list(package_list):
     '''Clean out the packages that won't be getting tests for Fedora.'''
     clean = []
     for package in package_list:
         pname, comment = package.split(',')
-        
+
         if "N/A" not in comment:
             clean.append(pname)
     return clean
 
+
 def parse_fork(project):
     '''Split out the information from a fork so we can update the status of the correct
     project.
@@ -99,6 +104,7 @@ def parse_fork(project):
 
     return project.split('/')[2]
 
+
 def update_project(project=None, poc=None, session=None):
     '''Query the database for an existing entry, if it exists, update it.
     If it doesn't exist, ignore it (since the database is pre-seeded with
@@ -120,18 +126,19 @@ def update_project(project=None, poc=None, session=None):
             proj.update_status(u"MIGRATED")
         else:
             pass
-            
+
         session.add(proj)
         session.commit()
         session.close()
 
+
 def main():
     '''Pull the data from the remote source, compare all items to what we have
     in the database and update anything that needs updated.
     '''
 
     session = get_session()
-    
+
     upstream_tests = requests.get(config.API_URL + "projects")
     upstream_tests = json.loads(upstream_tests.text)['projects']
 
@@ -152,13 +159,13 @@ def main():
 
     session.commit()
     session.close()
-            
+
 
 if __name__ == '__main__':
 
     parser = argparse.ArgumentParser(description='Script to update the local uf-monitor database.')
     parser.add_argument('--create', help='Initialize the database', action='store_true')
-    
+
     engine = create_engine(config.DATASTORE, echo=False)
 
     args = parser.parse_args()
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..05f2c97
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,17 @@
+# This is a common file where different test suites/linters can be configured.
+
+[flake8]
+# If you want to ignore a specific source code line, use '# noqa' comment. If
+# you want to ignore the whole file, add '# flake8: noqa' comment. Read more
+# documentation about flake8 at:
+# https://flake8.readthedocs.org/
+max-line-length=99
+
+[pep8]
+max-line-length=99
+
+[pytest]
+minversion=2.0
+python_functions=test should
+python_files=test_* functest_*
+addopts=--functional testing/ --cov-report=term-missing --cov libtaskotron

