Example #1
0
 def test_directives_correct_no_dupes(self):
     """
     Tests that a Location object properly returns a unique directive if the same directive
     is added multiple times.
     """
     directive = {"signature": "a:0.0.0.0:80:a.b.c:/"}
     handle_location = Location(**{"location": self.valid_location})
     for i in range(10):
         handle_location.directives = directive
     self.assertEqual(len(handle_location.directives), 1)
     self.assertEqual(directive, handle_location.directives[0])
     del handle_location
 def test_language_configuration_correct_python(self):
     """
     Tests that setting the language as Python gets the contents of the gunicorn key from the
     parameters. An ad hoc key is injected into the gunicorn parameters and is then retrieved.
     """
     parameters = {"language" : "python", "gunicorn" : {"test key" : "gunicorn"}}
     directive = { "signature" : "a:0.0.0.0:80:a.b.c:/", "parameters" : parameters}
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     handle_location.directives = directive
     self.assertTrue("gunicorn" in handle_location.language_configuration.values())
     del handle_location
 def test_language_configuration_correct_python_custom_values(self):
     """
     Tests that setting the language as Python gets Gunicorn to point to the specified address
     if its parameters are passed in.
     """
     parameters = {"language" : "python", "gunicorn" : {"ip" : "1.2.3.4", "port" : "1234"}}
     directive = { "signature" : "a:0.0.0.0:80:a.b.c:/", "parameters" : parameters}
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     handle_location.directives = directive
     self.assertEqual(handle_location.language_configuration["ip"], "1.2.3.4")
     self.assertEqual(handle_location.language_configuration["port"], "1234")
     del handle_location
 def test_language_configuration_correct_python_default_values(self):
     """
     Tests that setting the language as Python but not providing any configuration parameter for
     Gunicorn gets it to the default 127.0.0.1:8000 address.
     """
     parameters = {"language" : "python"}
     directive = { "signature" : "a:0.0.0.0:80:a.b.c:/", "parameters" : parameters}
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     handle_location.directives = directive
     self.assertEqual(handle_location.language_configuration["ip"], "127.0.0.1")
     self.assertEqual(handle_location.language_configuration["port"], "8000")
     del handle_location
 def test_directives_correct_no_dupes(self):
     """
     Tests that a Location object properly returns a unique directive if the same directive
     is added multiple times.
     """
     directive = { "signature" : "a:0.0.0.0:80:a.b.c:/"}
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     for i in range(10):
         handle_location.directives = directive
     self.assertEqual(len(handle_location.directives), 1)
     self.assertEqual(directive, handle_location.directives[0])
     del handle_location
 def test_build_correct(self):
     """
     Tests that the _build method properly turns the directives into unique alias entries.
     """
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     directives = [
                     { "signature" : "a:0.0.0.0:80:a.b.c.d:/"},
                     { "signature" : "b:0.0.0.0:80:a.b.c.d:/"},
                     ]
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.alias), 2)
     del handle_location
Example #7
0
 def test_language_configuration_correct_python_default_values(self):
     """
     Tests that setting the language as Python but not providing any configuration parameter for
     Gunicorn gets it to the default 127.0.0.1:8000 address.
     """
     parameters = {"language": "python"}
     directive = {
         "signature": "a:0.0.0.0:80:a.b.c:/",
         "parameters": parameters
     }
     handle_location = Location(**{"location": self.valid_location})
     handle_location.directives = directive
     self.assertEqual(handle_location.language_configuration["ip"],
                      "127.0.0.1")
     self.assertEqual(handle_location.language_configuration["port"],
                      "8000")
     del handle_location
Example #8
0
 def test_directives_correct(self):
     """
     Tests that a Location object properly returns the directives that were assigned to it.
     """
     directives = [{
         "signature": "a:0.0.0.0:80:a.b.c:/"
     }, {
         "signature": "a:0.0.0.0:8080:a.b.c:/"
     }]
     handle_location = Location(**{"location": self.valid_location})
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.directives), 2)
     for directive, expected_directive in zip(handle_location.directives,
                                              directives):
         self.assertEqual(directive, expected_directive)
     del handle_location
Example #9
0
 def test_build_correct(self):
     """
     Tests that the _build method properly turns the directives into unique alias entries.
     """
     handle_location = Location(**{"location": self.valid_location})
     directives = [
         {
             "signature": "a:0.0.0.0:80:a.b.c.d:/"
         },
         {
             "signature": "b:0.0.0.0:80:a.b.c.d:/"
         },
     ]
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.alias), 2)
     del handle_location
 def test_directives_correct(self):
     """
     Tests that a Location object properly returns the directives that were assigned to it.
     """
     directives = [
                     { "signature" : "a:0.0.0.0:80:a.b.c:/"},
                     { "signature" : "a:0.0.0.0:8080:a.b.c:/"}
                     ]
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.directives), 2)
     for directive, expected_directive in zip(handle_location.directives, directives):
         self.assertEqual(directive, expected_directive)
     del handle_location
 def test_build_correct_no_dupes(self):
     """
     Tests that the _build method properly generates a unique alias if provided with the same
     alias twice.
     """
     handle_location = Location(**{
                                     "location" : self.valid_location
                                     }
                                 )
     alias = "this_container"
     directives = [
                     { "signature" : "%s:0.0.0.0:80:a.b.c.d:/" % (alias)},
                     { "signature" : "%s:0.0.0.0:80:a.b.c.d:/" % (alias)},
                     ]
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.alias), 1)
     self.assertEqual(list(handle_location.alias)[0], alias)
     del handle_location
Example #12
0
 def test_language_configuration_correct_python(self):
     """
     Tests that setting the language as Python gets the contents of the gunicorn key from the
     parameters. An ad hoc key is injected into the gunicorn parameters and is then retrieved.
     """
     parameters = {
         "language": "python",
         "gunicorn": {
             "test key": "gunicorn"
         }
     }
     directive = {
         "signature": "a:0.0.0.0:80:a.b.c:/",
         "parameters": parameters
     }
     handle_location = Location(**{"location": self.valid_location})
     handle_location.directives = directive
     self.assertTrue(
         "gunicorn" in handle_location.language_configuration.values())
     del handle_location
Example #13
0
 def test_build_correct_no_dupes(self):
     """
     Tests that the _build method properly generates a unique alias if provided with the same
     alias twice.
     """
     handle_location = Location(**{"location": self.valid_location})
     alias = "this_container"
     directives = [
         {
             "signature": "%s:0.0.0.0:80:a.b.c.d:/" % (alias)
         },
         {
             "signature": "%s:0.0.0.0:80:a.b.c.d:/" % (alias)
         },
     ]
     for directive in directives:
         handle_location.directives = directive
     self.assertEqual(len(handle_location.alias), 1)
     self.assertEqual(list(handle_location.alias)[0], alias)
     del handle_location
Example #14
0
 def test_language_configuration_correct_python_custom_values(self):
     """
     Tests that setting the language as Python gets Gunicorn to point to the specified address
     if its parameters are passed in.
     """
     parameters = {
         "language": "python",
         "gunicorn": {
             "ip": "1.2.3.4",
             "port": "1234"
         }
     }
     directive = {
         "signature": "a:0.0.0.0:80:a.b.c:/",
         "parameters": parameters
     }
     handle_location = Location(**{"location": self.valid_location})
     handle_location.directives = directive
     self.assertEqual(handle_location.language_configuration["ip"],
                      "1.2.3.4")
     self.assertEqual(handle_location.language_configuration["port"],
                      "1234")
     del handle_location