1010import tempfile
1111import unittest
1212
13+
1314class ConfigTest (unittest .TestCase ):
1415
1516 def test_pom_template (self ):
@@ -126,6 +127,45 @@ def test_classifier__set_in_config__env_var_takes_precedence(self):
126127 finally :
127128 del os .environ ["POMGEN_JAR_CLASSIFIER" ]
128129
130+ def test_change_detection__default (self ):
131+ repo_root = tempfile .mkdtemp ("root" )
132+ os .mkdir (os .path .join (repo_root , "config" ))
133+ pom_template_path = self ._write_file (repo_root , "WORKSPACE" , "foo" )
134+ pom_template_path = self ._write_file (repo_root , "config/pom_template.xml" , "foo" )
135+ self ._write_file (repo_root , ".pomgenrc" , "" )
136+
137+ cfg = config .load (repo_root )
138+
139+ self .assertTrue (cfg .change_detection_enabled )
140+
141+ def test_change_detection__enabled (self ):
142+ repo_root = tempfile .mkdtemp ("root" )
143+ os .mkdir (os .path .join (repo_root , "config" ))
144+ pom_template_path = self ._write_file (repo_root , "WORKSPACE" , "foo" )
145+ pom_template_path = self ._write_file (repo_root , "config/pom_template.xml" , "foo" )
146+ self ._write_file (repo_root , ".pomgenrc" , """
147+ [artifact]
148+ change_detection_enabled=True
149+ """ )
150+
151+ cfg = config .load (repo_root )
152+
153+ self .assertTrue (cfg .change_detection_enabled )
154+
155+ def test_change_detection__disabled (self ):
156+ repo_root = tempfile .mkdtemp ("root" )
157+ os .mkdir (os .path .join (repo_root , "config" ))
158+ pom_template_path = self ._write_file (repo_root , "WORKSPACE" , "foo" )
159+ pom_template_path = self ._write_file (repo_root , "config/pom_template.xml" , "foo" )
160+ self ._write_file (repo_root , ".pomgenrc" , """
161+ [artifact]
162+ change_detection_enabled=False
163+ """ )
164+
165+ cfg = config .load (repo_root )
166+
167+ self .assertFalse (cfg .change_detection_enabled )
168+
129169 def test_str (self ):
130170 repo_root = tempfile .mkdtemp ("root" )
131171 pom_template_path = self ._write_file (repo_root , "pom_template" , "foo" )
@@ -136,24 +176,6 @@ def test_str(self):
136176 self .assertIn ("pom_template_path=%s" % pom_template_path , str (cfg ))
137177 self .assertIn ("maven_install_paths=('maven', 'misc')" , str (cfg ))
138178
139- def _write_pomgenrc (self , repo_root , pom_template_path , maven_install_paths ):
140- content = """[general]
141- pom_template_path=%s
142- """ % pom_template_path
143-
144- if maven_install_paths is not None :
145- content = content + """
146- maven_install_paths=%s
147- """ % maven_install_paths
148-
149- self ._write_file (repo_root , ".pomgenrc" , content )
150-
151- def _write_file (self , repo_root , relative_path , content ):
152- path = os .path .join (repo_root , relative_path )
153- with open (path , "w" ) as f :
154- f .write (content )
155- return path
156-
157179 def test_pathsep__excluded_dependency_paths (self ):
158180 cfg = config .Config (excluded_dependency_paths = "abc" )
159181 self .assertEqual ("abc/" , cfg .excluded_dependency_paths [0 ])
@@ -189,6 +211,25 @@ def test_tuple__excluded_src_file_extensions(self):
189211 self .assertTrue (isinstance (cfg .excluded_src_file_extensions , tuple ))
190212 self .assertEqual (0 , len (cfg .excluded_src_file_extensions ))
191213
214+ def _write_pomgenrc (self , repo_root , pom_template_path , maven_install_paths ):
215+ content = """[general]
216+ pom_template_path=%s
217+ """ % pom_template_path
218+
219+ if maven_install_paths is not None :
220+ content = content + """
221+ maven_install_paths=%s
222+ """ % maven_install_paths
223+
224+ self ._write_file (repo_root , ".pomgenrc" , content )
225+
226+ def _write_file (self , repo_root , relative_path , content ):
227+ path = os .path .join (repo_root , relative_path )
228+ with open (path , "w" ) as f :
229+ f .write (content )
230+ return path
231+
232+
192233if __name__ == '__main__' :
193234 unittest .main ()
194235
0 commit comments