Skip to content

Instantly share code, notes, and snippets.

@pep8speaks
Created June 25, 2019 08:34
Show Gist options
  • Save pep8speaks/51a9c948ef0877dd2fbda870753a84ee to your computer and use it in GitHub Desktop.
Save pep8speaks/51a9c948ef0877dd2fbda870753a84ee to your computer and use it in GitHub Desktop.
--- original/file_to_fix.py
+++ fixed/file_to_fix.py
@@ -1,3 +1,11 @@
+from mod_honeypot.models import Profile, PiModels, PiPotReport, ProfileService, \\
+ CollectorTypes, Deployment
+from mod_config.models import Service, Notification, Actions, Conditions, Rule
+from mod_auth.models import User, Role, Page, PageAccess
+from database import create_session, Base
+from flask import g, current_app
+from collections import namedtuple
+import tests.config
import os
import sys
import mock
@@ -7,14 +15,6 @@
# Need to append server root path to ensure we can import the necessary files.
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-import tests.config
-from collections import namedtuple
-from flask import g, current_app
-from database import create_session, Base
-from mod_auth.models import User, Role, Page, PageAccess
-from mod_config.models import Service, Notification, Actions, Conditions, Rule
-from mod_honeypot.models import Profile, PiModels, PiPotReport, ProfileService, \\
- CollectorTypes, Deployment
def generate_keys(tempdir):
@@ -38,20 +38,20 @@
secret_csrf = secret_csrf_file.read()
return {
- 'TESTING': True,
- 'WTF_CSRF_ENABLED': False,
- 'SQLALCHEMY_POOL_SIZE': 1,
- 'SECRET_KEY': secret_key,
- 'CSRF_SESSION_KEY': secret_csrf,
- 'SERVER_IP': '127.0.0.1',
- 'SERVER_PORT': 443,
- 'INSTANCE_NAME': 'testInstance',
- 'APPLICATION_ROOT': '/',
- 'CSRF_ENABLED': False,
- 'DATABASE_URI': tests.config.DATABASE_URI,
- 'COLLECTOR_UDP_PORT': 1234,
- 'COLLECTOR_SSL_PORT': 1235
- }
+ 'TESTING': True,
+ 'WTF_CSRF_ENABLED': False,
+ 'SQLALCHEMY_POOL_SIZE': 1,
+ 'SECRET_KEY': secret_key,
+ 'CSRF_SESSION_KEY': secret_csrf,
+ 'SERVER_IP': '127.0.0.1',
+ 'SERVER_PORT': 443,
+ 'INSTANCE_NAME': 'testInstance',
+ 'APPLICATION_ROOT': '/',
+ 'CSRF_ENABLED': False,
+ 'DATABASE_URI': tests.config.DATABASE_URI,
+ 'COLLECTOR_UDP_PORT': 1234,
+ 'COLLECTOR_SSL_PORT': 1235
+ }
class BasicTestCase(unittest.TestCase):
--- original/file_to_fix.py
+++ fixed/file_to_fix.py
@@ -1,3 +1,4 @@
+from decorators import get_menu_entries, get_permissible_entries
import unittest
import os
import sys
@@ -6,7 +7,6 @@
# Need to append server root path to ensure we can import the necessary files.
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-from decorators import get_menu_entries, get_permissible_entries
class TestGetMenuEntries(unittest.TestCase):
@@ -46,10 +46,10 @@
{'title': 'Honeypot services', 'route': 'config.services',
'entries': [{'title': 'Profile mgmt', 'route': 'honeypot.profiles', 'icon': 'bookmark'}],
'icon': 'sliders'}], 'icon': 'bell-o'}], 'icon': 'bell-o'},
- {'route': 'config.data_processing', 'title': 'Data processing',
- 'icon': 'exchange'},
- {'route': 'config.services', 'title': 'Honeypot services', 'icon': 'sliders'}],
- 'icon': 'cog', 'title': 'Configuration'}
+ {'route': 'config.data_processing', 'title': 'Data processing',
+ 'icon': 'exchange'},
+ {'route': 'config.services', 'title': 'Honeypot services', 'icon': 'sliders'}],
+ 'icon': 'cog', 'title': 'Configuration'}
calls = [
call(mu, {'route': 'config.notifications', 'icon': 'bell-o', 'entries': [
{'route': 'config.notifications', 'icon': 'bell-o', 'entries': [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment