44import pytest
55
66import reflex as rx
7- from reflex import Component , constants
7+ from reflex import constants
88from reflex .app import App
99from reflex .sitemap import (
1010 generate_links_for_sitemap ,
2323
2424@pytest .fixture
2525def app_instance ():
26- """Fixture to create an instance of the app."""
26+ """Fixture to create an instance of the app.
27+
28+ Returns:
29+ An instance of the App class.
30+ """
2731 app = App ()
2832 return app
2933
3034
31- class Page ( Component ):
32- """A simple Page component."""
35+ def page ( text : str ):
36+ """A simple page component for testing.
3337
34- def __init__ (self , text , ** kwargs ):
35- """Initialize the Page component."""
36- super ().__init__ (** kwargs )
37- self .text = text
38+ Args:
39+ text: The text to display on the page.
3840
39- def render (self ):
40- """Render the Page component."""
41- return rx .box (self .text )
41+ Returns:
42+ A Reflex component with the given text.
43+ """
44+ return rx .box (text )
4245
4346
4447@pytest .fixture
45- def index_page () -> Page :
48+ def index_page ():
4649 """Fixture that returns an IndexPage instance.
4750
4851 Returns:
4952 An instance of IndexPage.
5053 """
51- return Page (text = "Index" )
54+ return page (text = "Index" )
5255
5356
5457@pytest .fixture
55- def about_page () -> Page :
58+ def about_page ():
5659 """Fixture that returns an AboutPage instance.
5760
5861 Returns:
5962 An instance of AboutPage.
6063 """
61- return Page (text = "About" )
64+ return page (text = "About" )
6265
6366
6467mock_xml = """<?xml version="1.0" ?>
@@ -89,7 +92,13 @@ def test_generate_xml():
8992
9093
9194def test_generate_static_sitemaps (app_instance , index_page , about_page ):
92- """Test if the generated sitemap file is currently stored in static website or not."""
95+ """Test if the generated sitemap file is currently stored in static website or not.
96+
97+ Args:
98+ app_instance: The app instance.
99+ index_page: The index page fixture.
100+ about_page: The about page fixture.
101+ """
93102 pages = {"index" : index_page , "about" : about_page }
94103 # remove the sitemap.xml file if it exists.
95104 sitemap_file_path .unlink (missing_ok = True )
@@ -107,12 +116,12 @@ def test_generate_links_for_sitemap():
107116 """Test if the links are generated correctly for the sitemap from the sitemap config file when no deploy url is
108117 given.
109118 """
110- sitemap_properties = {
111- "index" : { "priority" : 0.9 , "changefreq" : "weekly" },
112- "about " : {"priority" : 0.9 , "changefreq" : "weekly" },
113- }
114-
115- links = generate_links_for_sitemap ( sitemap_properties )
119+ links = generate_links_for_sitemap (
120+ {
121+ "index " : {"priority" : 0.9 , "changefreq" : "weekly" },
122+ "about" : { "priority" : 0.9 , "changefreq" : "weekly" },
123+ }
124+ )
116125
117126 # Assert that the links are generated correctly
118127 assert links == [
@@ -129,15 +138,15 @@ def test_generate_links_for_sitemap_deploy_url():
129138 """Test if the links are generated correctly for the sitemap from the sitemap config file when a deploy url is
130139 given.
131140 """
132- sitemap_properties = {
133- "index" : {"priority" : 0.9 , "changefreq" : "weekly" },
134- "about" : {"priority" : 0.9 , "changefreq" : "weekly" },
135- }
136-
137141 with unittest .mock .patch ("reflex.sitemap.get_config" ) as mock_get_config :
138142 mock_get_config ().deploy_url = "http://www.google.com"
139143
140- links = generate_links_for_sitemap (sitemap_properties )
144+ links = generate_links_for_sitemap (
145+ {
146+ "index" : {"priority" : 0.9 , "changefreq" : "weekly" },
147+ "about" : {"priority" : 0.9 , "changefreq" : "weekly" },
148+ }
149+ )
141150
142151 # Assert that the links are generated correctly
143152 assert links == [
0 commit comments