def test_init_and_new_command_with_call_command(): create_path = os.path.join(tempfile.mkdtemp()) try: shutil.rmtree(create_path) except FileNotFoundError: pass call_command(argv=["init", "tester", "--app-dir", create_path]) app_dir = os.path.join(create_path, "tester") app_path = os.path.join(app_dir, "tester.py") call_command(argv=["new_command", "testit", "--app-path", app_path]) assert os.path.exists(os.path.join(app_dir, "commands", "testit.py")) shutil.rmtree(create_path)
def test_init_with_call_command(): create_path = os.path.join(tempfile.mkdtemp()) try: shutil.rmtree(create_path) except FileNotFoundError: pass call_command(argv=["init", "tester", "--app-dir", create_path]) app_path = os.path.join(create_path, "tester") assert os.path.exists(app_path) assert os.path.isdir(app_path) _glob = ["tester.py", "tests.py", "commands", "__init__.py", "settings.py", "tests.py", "schemas.py"] created = os.listdir(app_path) for thing in _glob: assert thing in created shutil.rmtree(create_path)
def test_init_with_call_command(): create_path = os.path.join(tempfile.mkdtemp()) try: shutil.rmtree(create_path) except FileNotFoundError: pass call_command(argv=["init", "tester", "--app-dir", create_path]) app_path = os.path.join(create_path, "tester") assert os.path.exists(app_path) assert os.path.isdir(app_path) _glob = [ "tester.py", "tests.py", "commands", "__init__.py", "settings.py", "tests.py", "schemas.py" ] created = os.listdir(app_path) for thing in _glob: assert thing in created shutil.rmtree(create_path)
def test_yawf_main_working_module_fake(mock_load_settings, mock_run): call_command(argv=["test", "--app-path", "/this/fake/path/modulex.py"]) assert mock_load_settings.called mock_load_settings.assert_called_with("/this/fake/path/modulex.py") assert mock_run.called mock_run.assert_called_with([], "modulex.commands.test", None)
def test_yawf_main_working_module(mock_load_settings): with pytest.raises(SystemExit) as err: call_command(argv=["test", "--app-path", "/this/fake/path/modulex.py"]) assert err == "command `test` not found." assert mock_load_settings.called mock_load_settings.assert_called_with("/this/fake/path/modulex.py")
def test_yawf_main_with_app_path(): with pytest.raises(ImportError): call_command(argv=["test", "--app-path", "/this/fake/path/modulex.py"])
def test_yawf_main_no_input(): with pytest.raises(SystemExit): call_command(argv=[])
def test_yawf_main_command_not_found(): with pytest.raises(SystemExit) as err: call_command(argv=["doesnotexist"]) assert err == "command `doesnotexist` not found."