Changeset - ba26a581c827
[Not reviewed]
default
0 8 0
Branko Majic (branko) - 6 years ago 2017-12-21 12:25:33
branko@majic.rs
CONNT-25: Updating appliction and project to use Django 1.6.x:

- Fixed tests to denote that ordering is not important in a number of
queryset tests.
- Replaced deprecated parameter name mimetype with content_type in views.
- Updated development requirements and setup script to depend on Django 1.6.x.
- Removed requirement for django-discover-runner, which is now incorporated
into Django itself and works out of the box.
- Updated development requirements to include pytz (needed for USE_TZ = True
setting).
8 files changed with 25 insertions and 32 deletions:
0 comments (0 inline, 0 general)
conntrackt/tests/test_views.py
Show inline comments
 
@@ -161,24 +161,24 @@ class ProjectViewTest(RenderTestMixin, P
 
        # Set-up expected context data values.
 
        expected_entities = ["<Entity: Test Entity 1 (Test Project 1 - Test Location 1)>",
 
                             "<Entity: Test Entity 2 (Test Project 1 - Test Location 1)>"]
 

	
 
        # Validate context data.
 
        self.assertEqual(location.name, "Test Location 1")
 
        self.assertQuerysetEqual(entities, expected_entities)
 
        self.assertQuerysetEqual(entities, expected_entities, ordered=False)
 

	
 
        # Fetch context data from response.
 
        location, entities = response.context_data["location_entities"][1]
 

	
 
        # Set-up expected context data values.
 
        expected_entities = ["<Entity: Test Entity 3 (Test Project 1 - Test Location 2)>",
 
                             "<Entity: Test Subnet 4 (Test Project 1 - Test Location 2)>"]
 

	
 
        # Validate context data.
 
        self.assertEqual(location.name, "Test Location 2")
 
        self.assertQuerysetEqual(entities, expected_entities)
 
        self.assertQuerysetEqual(entities, expected_entities, ordered=False)
 

	
 
        # Validate context data.
 
        self.assertEqual(str(response.context_data["project"]), "Test Project 1")
 

	
 
        # Validate context data is present.
 
        self.assertIn("communications", response.context_data.keys())
 
@@ -908,13 +908,13 @@ class InterfaceUpdateViewTest(RenderTest
 

	
 
        expected_entities = ["<Entity: Test Entity 1 (Test Project 1 - Test Location 1)>",
 
                             "<Entity: Test Entity 2 (Test Project 1 - Test Location 1)>",
 
                             "<Entity: Test Entity 3 (Test Project 1 - Test Location 2)>",
 
                             "<Entity: Test Subnet 4 (Test Project 1 - Test Location 2)>"]
 

	
 
        self.assertQuerysetEqual(form.fields["entity"].queryset, expected_entities)
 
        self.assertQuerysetEqual(form.fields["entity"].queryset, expected_entities, ordered=False)
 

	
 
    def test_success_url(self):
 
        """
 
        Validate that the success URL is set properly after update.
 
        """
 

	
 
@@ -1046,14 +1046,14 @@ class CommunicationCreateViewTest(Render
 
        form = view.get_form(view.get_form_class())
 

	
 
        # Set-up expected interfaces.
 
        expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>",
 
                               "<Interface: Test Entity 2 (192.168.1.2)>"]
 

	
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces, ordered = False)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces, ordered = False)
 

	
 
    def test_interface_limit_to_entity(self):
 
        """
 
        Tests if the queryset is properly limitted if GET parameter is passed.
 
        """
 

	
 
@@ -1066,14 +1066,14 @@ class CommunicationCreateViewTest(Render
 
        form = view.get_form(view.get_form_class())
 

	
 
        # Set-up expected interfaces.
 
        expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>",
 
                               "<Interface: Test Entity 2 (192.168.1.2)>"]
 

	
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces, ordered=False)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces, ordered=False)
 

	
 
    def test_interface_limit_project(self):
 
        """
 
        Tests if the queryset is properly limitted if GET parameter is passed.
 
        """
 

	
 
@@ -1086,14 +1086,14 @@ class CommunicationCreateViewTest(Render
 
        form = view.get_form(view.get_form_class())
 

	
 
        # Set-up expected interfaces.
 
        expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>",
 
                               "<Interface: Test Entity 2 (192.168.1.2)>"]
 

	
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces, ordered=False)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces, ordered=False)
 

	
 
    def test_initial_from_entity(self):
 
        """
 
        Tests if the choice field for interface is defaulted to first interface
 
        of entity passed as part of GET parameters.
 
        """
 
@@ -1280,14 +1280,14 @@ class CommunicationUpdateViewTest(Render
 

	
 
        expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>",
 
                               "<Interface: Test Entity 2 (192.168.1.2)>",
 
                               "<Interface: Test Entity 3 (192.168.1.3)>",
 
                               "<Interface: Test Subnet 4 (10.10.4.0/255.255.255.0)>"]
 

	
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces)
 
        self.assertQuerysetEqual(form.fields["source"].queryset, expected_interfaces, ordered=False)
 
        self.assertQuerysetEqual(form.fields["destination"].queryset, expected_interfaces, ordered=False)
 

	
 
    def test_success_url_next(self):
 
        """
 
        Validate that the success URL is set properly after update if GET
 
        parameter is passed.
 
        """
conntrackt/views.py
Show inline comments
 
@@ -253,13 +253,13 @@ def entity_iptables(request, pk):
 
    """
 

	
 
    # Fetch the entity, and construct the response with iptables rules as
 
    # content.
 
    entity = get_object_or_404(Entity, pk=pk)
 
    content = generate_entity_iptables(entity)
 
    response = HttpResponse(content, mimetype='text/plain')
 
    response = HttpResponse(content, content_type='text/plain')
 

	
 
    # Add the Content-Disposition information for the browser, telling the
 
    # browser to download the file with suggested filename.
 
    response['Content-Disposition'] = "attachment; filename=%s-iptables.conf" % entity.name.lower().replace(" ", "_")
 

	
 
    return response
 
@@ -296,13 +296,13 @@ def project_iptables(request, project_id
 

	
 
    # Create a new ZIP file in-memory.
 
    zipped_iptables = ZipFile(buff, "w", ZIP_DEFLATED)
 

	
 
    # Create the response object, setting the mime type so browser could offer
 
    # to open the file with program as well.
 
    response = HttpResponse(mimetype='application/zip')
 
    response = HttpResponse(content_type='application/zip')
 

	
 
    # If specific location was specified, get the entities that are part of that
 
    # project location only, otherwise fetch all of the project's entities. Also
 
    # set-up the filename that will be suggested to the browser.
 
    if location_id:
 
        location = get_object_or_404(Location, pk=location_id)
 
@@ -1002,13 +1002,13 @@ def project_diagram(request, pk):
 
    project = get_object_or_404(Project, pk=pk)
 

	
 
    # Generate the diagram.
 
    content = generate_project_diagram(project).create_svg()
 

	
 
    # Set the mime type.
 
    response = HttpResponse(content, mimetype='image/svg+xml')
 
    response = HttpResponse(content, content_type='image/svg+xml')
 

	
 
    # Return the response object.
 
    return response
 

	
 

	
 
class SearchView(MultiplePermissionsRequiredMixin, TemplateView):
 
@@ -1126,10 +1126,10 @@ class APISearchView(MultiplePermissionsR
 
                              "project": project.name,
 
                              "type": "project",
 
                              "url": project.get_absolute_url()})
 

	
 
        # Generate the JSON response.
 
        content = json.dumps(items)
 
        response = HttpResponse(content, mimetype="application/json")
 
        response = HttpResponse(content, content_type="application/json")
 

	
 
        # Return the response.
 
        return response
requirements/base.in
Show inline comments
 
@@ -21,13 +21,13 @@
 
django-braces~=1.12.0
 

	
 
# Convenience tools for controlling rendering of forms while embracing DRY.
 
django-crispy-forms~=1.6.0
 

	
 
# Web framework used by application.
 
django~=1.5.0
 
django~=1.6.0
 

	
 
# Library for programatic calculation of colours (contrasts,
 
# inversions etc).
 
palette~=0.2.0
 

	
 
# Interaface towards Graphviz for chart generation.
requirements/development.in
Show inline comments
 
@@ -19,17 +19,17 @@
 

	
 
-r base.in
 

	
 
# Used for generating test code coverage report.
 
coverage~=4.4.0
 

	
 
# Convenience test runner tailored for running Django tests.
 
django-discover-runner~=0.3.0
 

	
 
# Used for dynamic generation of fixture data in tests.
 
factory_boy~=2.1.0
 

	
 
# Used for mocking in unit tests.
 
mock~=1.3.0
 

	
 
# Used for building documentation.
 
sphinx~=1.6.0
 
\ No newline at end of file
 
sphinx~=1.6.0
 

	
 
# Used for handling of timezones.
 
pytz
 
\ No newline at end of file
requirements/development.txt
Show inline comments
 
@@ -8,14 +8,13 @@ alabaster==0.7.10         # via sphinx
 
babel==2.5.1              # via sphinx
 
certifi==2017.11.5        # via requests
 
chardet==3.0.4            # via requests
 
coverage==4.4.2
 
django-braces==1.12.0
 
django-crispy-forms==1.6.1
 
django-discover-runner==0.3
 
django==1.5.12
 
django==1.6.11
 
docutils==0.14            # via sphinx
 
factory-boy==2.1.2
 
funcsigs==1.0.2           # via mock
 
idna==2.6                 # via requests
 
imagesize==0.7.1          # via sphinx
 
jinja2==2.10              # via sphinx
 
@@ -23,13 +22,13 @@ markupsafe==1.0           # via jinja2
 
mock==1.3.0
 
palette==0.2
 
pbr==3.1.1                # via mock
 
pydot==1.2.3
 
pygments==2.2.0           # via sphinx
 
pyparsing==2.2.0          # via pydot
 
pytz==2017.3              # via babel
 
pytz==2017.3
 
requests==2.18.4          # via sphinx
 
six==1.11.0               # via mock, sphinx
 
snowballstemmer==1.2.1    # via sphinx
 
south==1.0.2
 
sphinx==1.6.5
 
sphinxcontrib-websupport==1.0.1  # via sphinx
requirements/test.txt
Show inline comments
 
@@ -8,14 +8,13 @@ alabaster==0.7.10         # via sphinx
 
babel==2.5.1              # via sphinx
 
certifi==2017.11.5        # via requests
 
chardet==3.0.4            # via requests
 
coverage==4.4.2
 
django-braces==1.12.0
 
django-crispy-forms==1.6.1
 
django-discover-runner==0.3
 
django==1.5.12
 
django==1.6.11
 
docutils==0.14            # via sphinx
 
factory-boy==2.1.2
 
funcsigs==1.0.2           # via mock
 
idna==2.6                 # via requests
 
imagesize==0.7.1          # via sphinx
 
jinja2==2.10              # via sphinx
 
@@ -23,13 +22,13 @@ markupsafe==1.0           # via jinja2
 
mock==1.3.0
 
palette==0.2
 
pbr==3.1.1                # via mock
 
pydot==1.2.3
 
pygments==2.2.0           # via sphinx
 
pyparsing==2.2.0          # via pydot
 
pytz==2017.3              # via babel
 
pytz==2017.3
 
requests==2.18.4          # via sphinx
 
six==1.11.0               # via mock, sphinx
 
snowballstemmer==1.2.1    # via sphinx
 
south==1.0.2
 
sphinx==1.6.5
 
sphinxcontrib-websupport==1.0.1  # via sphinx
setup.py
Show inline comments
 
@@ -23,13 +23,13 @@ import os
 
from setuptools import setup, find_packages
 

	
 
README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
 
INSTALL_REQUIREMENTS = [
 
    "django-braces~=1.12.0",
 
    "django-crispy-forms~=1.6.0",
 
    "django~=1.5.0",
 
    "django~=1.6.0",
 
    "palette~=0.2.0",
 
    "pydot~=1.2.0",
 
    "south~=1.0.0",
 
]
 

	
 
# allow setup.py to be run from any path
testproject/testproject/settings.py
Show inline comments
 
@@ -149,14 +149,12 @@ INSTALLED_APPS = (
 
    # Enable the conntrackt application
 
    'conntrackt',
 
    # Database migrations
 
    'south',
 
    # Generic mixins for Django.
 
    'braces',
 
    # Enable test-runner.
 
    'discover_runner',
 
    # Better forms, including styling functions.
 
    'crispy_forms',
 
)
 

	
 
# A sample logging configuration. The only tangible logging
 
# performed by this configuration is to send an email to
 
@@ -186,9 +184,6 @@ LOGGING = {
 
        },
 
    }
 
}
 

	
 
# View that should be called for log-in action.
 
LOGIN_URL = "login"
 

	
 
# Use custom test runner.
 
TEST_RUNNER = 'discover_runner.DiscoverRunner'
0 comments (0 inline, 0 general)