6 7 def test_python_environment_name_null(self): 8 self.load('environment') 9 10 self.assertIn( 11 'error', 12 self.conf( 13 {"va\0r": "val1"}, 'applications/environment/environment' 14 ), 15 'name null', 16 ) 17 18 def test_python_environment_name_equals(self): 19 self.load('environment') 20 21 self.assertIn( 22 'error', 23 self.conf( 24 {"var=": "val1"}, 'applications/environment/environment' 25 ), 26 'name equals', 27 ) 28 29 def test_python_environment_value_null(self): 30 self.load('environment') 31 32 self.assertIn( 33 'error', 34 self.conf( 35 {"var": "\0val"}, 'applications/environment/environment' 36 ), 37 'value null', 38 ) 39 40 def test_python_environment_update(self): 41 self.load('environment') 42 43 self.conf({"var": "val1"}, 'applications/environment/environment') 44 45 self.assertEqual( 46 self.get( 47 headers={ 48 'Host': 'localhost', 49 'X-Variables': 'var', 50 'Connection': 'close', 51 } 52 )['body'], 53 'val1,', 54 'set', 55 ) 56 57 self.conf({"var": "val2"}, 'applications/environment/environment') 58 59 self.assertEqual( 60 self.get( 61 headers={ 62 'Host': 'localhost', 63 'X-Variables': 'var', 64 'Connection': 'close', 65 } 66 )['body'], 67 'val2,', 68 'update', 69 ) 70 71 def test_python_environment_replace(self): 72 self.load('environment') 73 74 self.conf({"var1": "val1"}, 'applications/environment/environment') 75 76 self.assertEqual( 77 self.get( 78 headers={ 79 'Host': 'localhost', 80 'X-Variables': 'var1', 81 'Connection': 'close', 82 } 83 )['body'], 84 'val1,', 85 'set', 86 ) 87 88 self.conf({"var2": "val2"}, 'applications/environment/environment') 89 90 self.assertEqual( 91 self.get( 92 headers={ 93 'Host': 'localhost', 94 'X-Variables': 'var1,var2', 95 'Connection': 'close', 96 } 97 )['body'], 98 'val2,', 99 'replace', 100 ) 101 102 def test_python_environment_clear(self): 103 self.load('environment') 104 105 self.conf( 106 {"var1": "val1", "var2": "val2"}, 107 'applications/environment/environment', 108 ) 109 110 self.assertEqual( 111 self.get( 112 headers={ 113 'Host': 'localhost', 114 'X-Variables': 'var1,var2', 115 'Connection': 'close', 116 } 117 )['body'], 118 'val1,val2,', 119 'set', 120 ) 121 122 self.conf({}, 'applications/environment/environment') 123 124 self.assertEqual( 125 self.get( 126 headers={ 127 'Host': 'localhost', 128 'X-Variables': 'var1,var2', 129 'Connection': 'close', 130 } 131 )['body'], 132 '', 133 'clear', 134 ) 135 136 def test_python_environment_replace_default(self): 137 self.load('environment') 138 139 home_default = self.get( 140 headers={ 141 'Host': 'localhost', 142 'X-Variables': 'HOME', 143 'Connection': 'close', 144 } 145 )['body'] 146 147 self.assertGreater(len(home_default), 1, 'get default') 148 149 self.conf({"HOME": "/"}, 'applications/environment/environment') 150 151 self.assertEqual( 152 self.get( 153 headers={ 154 'Host': 'localhost', 155 'X-Variables': 'HOME', 156 'Connection': 'close', 157 } 158 )['body'], 159 '/,', 160 'replace default', 161 ) 162 163 self.conf({}, 'applications/environment/environment') 164 165 self.assertEqual( 166 self.get( 167 headers={ 168 'Host': 'localhost', 169 'X-Variables': 'HOME', 170 'Connection': 'close', 171 } 172 )['body'], 173 home_default, 174 'restore default', 175 ) 176 177 178if __name__ == '__main__': 179 TestPythonEnvironment.main()
| 6 7 def test_python_environment_name_null(self): 8 self.load('environment') 9 10 self.assertIn( 11 'error', 12 self.conf( 13 {"va\0r": "val1"}, 'applications/environment/environment' 14 ), 15 'name null', 16 ) 17 18 def test_python_environment_name_equals(self): 19 self.load('environment') 20 21 self.assertIn( 22 'error', 23 self.conf( 24 {"var=": "val1"}, 'applications/environment/environment' 25 ), 26 'name equals', 27 ) 28 29 def test_python_environment_value_null(self): 30 self.load('environment') 31 32 self.assertIn( 33 'error', 34 self.conf( 35 {"var": "\0val"}, 'applications/environment/environment' 36 ), 37 'value null', 38 ) 39 40 def test_python_environment_update(self): 41 self.load('environment') 42 43 self.conf({"var": "val1"}, 'applications/environment/environment') 44 45 self.assertEqual( 46 self.get( 47 headers={ 48 'Host': 'localhost', 49 'X-Variables': 'var', 50 'Connection': 'close', 51 } 52 )['body'], 53 'val1,', 54 'set', 55 ) 56 57 self.conf({"var": "val2"}, 'applications/environment/environment') 58 59 self.assertEqual( 60 self.get( 61 headers={ 62 'Host': 'localhost', 63 'X-Variables': 'var', 64 'Connection': 'close', 65 } 66 )['body'], 67 'val2,', 68 'update', 69 ) 70 71 def test_python_environment_replace(self): 72 self.load('environment') 73 74 self.conf({"var1": "val1"}, 'applications/environment/environment') 75 76 self.assertEqual( 77 self.get( 78 headers={ 79 'Host': 'localhost', 80 'X-Variables': 'var1', 81 'Connection': 'close', 82 } 83 )['body'], 84 'val1,', 85 'set', 86 ) 87 88 self.conf({"var2": "val2"}, 'applications/environment/environment') 89 90 self.assertEqual( 91 self.get( 92 headers={ 93 'Host': 'localhost', 94 'X-Variables': 'var1,var2', 95 'Connection': 'close', 96 } 97 )['body'], 98 'val2,', 99 'replace', 100 ) 101 102 def test_python_environment_clear(self): 103 self.load('environment') 104 105 self.conf( 106 {"var1": "val1", "var2": "val2"}, 107 'applications/environment/environment', 108 ) 109 110 self.assertEqual( 111 self.get( 112 headers={ 113 'Host': 'localhost', 114 'X-Variables': 'var1,var2', 115 'Connection': 'close', 116 } 117 )['body'], 118 'val1,val2,', 119 'set', 120 ) 121 122 self.conf({}, 'applications/environment/environment') 123 124 self.assertEqual( 125 self.get( 126 headers={ 127 'Host': 'localhost', 128 'X-Variables': 'var1,var2', 129 'Connection': 'close', 130 } 131 )['body'], 132 '', 133 'clear', 134 ) 135 136 def test_python_environment_replace_default(self): 137 self.load('environment') 138 139 home_default = self.get( 140 headers={ 141 'Host': 'localhost', 142 'X-Variables': 'HOME', 143 'Connection': 'close', 144 } 145 )['body'] 146 147 self.assertGreater(len(home_default), 1, 'get default') 148 149 self.conf({"HOME": "/"}, 'applications/environment/environment') 150 151 self.assertEqual( 152 self.get( 153 headers={ 154 'Host': 'localhost', 155 'X-Variables': 'HOME', 156 'Connection': 'close', 157 } 158 )['body'], 159 '/,', 160 'replace default', 161 ) 162 163 self.conf({}, 'applications/environment/environment') 164 165 self.assertEqual( 166 self.get( 167 headers={ 168 'Host': 'localhost', 169 'X-Variables': 'HOME', 170 'Connection': 'close', 171 } 172 )['body'], 173 home_default, 174 'restore default', 175 ) 176 177 178if __name__ == '__main__': 179 TestPythonEnvironment.main()
|