| 1458 | |
| 1459 | |
| 1460 | def 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 | """ |
| 1471 | import reflex as rx |
| 1472 | |
| 1473 | config = 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 | """ |
| 1484 | import reflex as rx |
| 1485 | from foo.components import views |
| 1486 | from foo.components.views import * |
| 1487 | from .base import * |
| 1488 | |
| 1489 | def random_component(): |
| 1490 | return rx.fragment() |
| 1491 | """ |
| 1492 | ) |
| 1493 | (foo_dir / "foo" / "foo.py").touch() |
| 1494 | (foo_dir / "foo" / "foo.py").write_text( |
| 1495 | """ |
| 1496 | import reflex as rx |
| 1497 | import foo.components.base |
| 1498 | from foo.components.base import random_component |
| 1499 | |
| 1500 | class State(rx.State): |
| 1501 | pass |
| 1502 | |
| 1503 | |
| 1504 | def index(): |
| 1505 | return rx.text("Hello, World!") |
| 1506 | |
| 1507 | app = rx.App() |
| 1508 | app.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 | """ |