MCPcopy
hub / github.com/reflex-dev/reflex / test_cli_rename_command

Function test_cli_rename_command

tests/units/test_prerequisites.py:1460–1556  ·  view source on GitHub ↗
(temp_directory)

Source from the content-addressed store, hash-verified

1458
1459
1460def test_cli_rename_command(temp_directory):
1461 foo_dir = temp_directory / "foo"
1462 foo_dir.mkdir()
1463 (foo_dir / "__init__").touch()
1464 (foo_dir / ".web").mkdir()
1465 (foo_dir / "assets").mkdir()
1466 (foo_dir / "foo").mkdir()
1467 (foo_dir / "foo" / "__init__.py").touch()
1468 (foo_dir / "rxconfig.py").touch()
1469 (foo_dir / "rxconfig.py").write_text(
1470 """
1471import reflex as rx
1472
1473config = rx.Config(
1474 app_name="foo",
1475)
1476"""
1477 )
1478 (foo_dir / "foo" / "components").mkdir()
1479 (foo_dir / "foo" / "components" / "__init__.py").touch()
1480 (foo_dir / "foo" / "components" / "base.py").touch()
1481 (foo_dir / "foo" / "components" / "views.py").touch()
1482 (foo_dir / "foo" / "components" / "base.py").write_text(
1483 """
1484import reflex as rx
1485from foo.components import views
1486from foo.components.views import *
1487from .base import *
1488
1489def random_component():
1490 return rx.fragment()
1491"""
1492 )
1493 (foo_dir / "foo" / "foo.py").touch()
1494 (foo_dir / "foo" / "foo.py").write_text(
1495 """
1496import reflex as rx
1497import foo.components.base
1498from foo.components.base import random_component
1499
1500class State(rx.State):
1501 pass
1502
1503
1504def index():
1505 return rx.text("Hello, World!")
1506
1507app = rx.App()
1508app.add_page(index)
1509"""
1510 )
1511
1512 with chdir(temp_directory / "foo"):
1513 result = runner.invoke(cli, ["rename", "bar"])
1514
1515 assert result.exit_code == 0, result.output
1516 assert (foo_dir / "rxconfig.py").read_text() == (
1517 """

Callers

nothing calls this directly

Calls 2

chdirClass · 0.90
existsMethod · 0.80

Tested by

no test coverage detected