def test_assert_dexy_dirs(): with tempdir(): wrapper = Wrapper() try: wrapper.assert_dexy_dirs_exist() assert False except UserFeedback: assert True
def test_deprecated_dot_dexy_file(): with tempdir(): with open(".dexy", 'w') as f: f.write("{}") wrapper = Wrapper() try: wrapper.assert_dexy_dirs_exist() except UserFeedback as e: assert "this format is no longer supported" in str(e)
def test_move_cache_dir(): with capture_stdout() as stdout: with tempdir(): os.mkdir(".cache") with open(".cache/.dexy-generated", 'w') as f: f.write("") wrapper = Wrapper() wrapper.assert_dexy_dirs_exist() assert "Moving directory '.cache'" in stdout.getvalue() assert not os.path.exists(".cache") assert os.path.exists(".dexy")
def test_old_cache_dir_with_settings(): with capture_stdout() as stdout: with tempdir(): os.mkdir(".cache") with open(".cache/.dexy-generated", 'w') as f: f.write("") wrapper = Wrapper(artifacts_dir = ".cache") wrapper.assert_dexy_dirs_exist() assert os.path.exists(".cache") assert not os.path.exists(".dexy") assert "You may have a dexy.conf file" in stdout.getvalue()
def test_old_cache_dir_with_settings(): with capture_stdout() as stdout: with tempdir(): os.mkdir(".cache") with open(".cache/.dexy-generated", 'w') as f: f.write("") wrapper = Wrapper(artifacts_dir=".cache") wrapper.assert_dexy_dirs_exist() assert os.path.exists(".cache") assert not os.path.exists(".dexy") assert "You may have a dexy.conf file" in stdout.getvalue()
def test_cache_and_dexy_dirs_present(): with tempdir(): os.mkdir(".dexy") os.mkdir(".cache") with open(".dexy/.dexy-generated", 'w') as f: f.write("") with open(".cache/.dexy-generated", 'w') as f: f.write("") wrapper = Wrapper() try: wrapper.assert_dexy_dirs_exist() except UserFeedback as e: assert "Please remove '.cache'" in str(e) os.remove(".cache/.dexy-generated") wrapper.assert_dexy_dirs_exist() # Cache still exists but dexy just ignores it. assert os.path.exists(".cache") # Dexy uses .dexy dir assert os.path.exists(".dexy")