Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 99560ea

Browse files
byronbyronz
authored andcommitted
🚚 move all under tests, so it's consistent across dash
1 parent 72ea98b commit 99560ea

20 files changed

+144
-144
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/test_integration.py renamed to tests/test_integration.py

Lines changed: 144 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -71,150 +71,150 @@ def snapshot(self, name):
7171
print("Percy Snapshot {}".format(python_version))
7272
self.percy_runner.snapshot(name=name)
7373

74-
def create_upload_component_content_types_test(self, filename):
75-
app = dash.Dash(__name__)
76-
77-
filepath = os.path.join(os.getcwd(), 'test', 'upload-assets', filename)
78-
79-
pre_style = {
80-
'whiteSpace': 'pre-wrap',
81-
'wordBreak': 'break-all'
82-
}
83-
84-
app.layout = html.Div([
85-
html.Div(filepath, id='waitfor'),
86-
html.Div(
87-
id='upload-div',
88-
children=dcc.Upload(
89-
id='upload',
90-
children=html.Div([
91-
'Drag and Drop or ',
92-
html.A('Select a File')
93-
]),
94-
style={
95-
'width': '100%',
96-
'height': '60px',
97-
'lineHeight': '60px',
98-
'borderWidth': '1px',
99-
'borderStyle': 'dashed',
100-
'borderRadius': '5px',
101-
'textAlign': 'center'
102-
}
103-
)
104-
),
105-
html.Div(id='output'),
106-
html.Div(DataTable(data=[{}]), style={'display': 'none'})
107-
])
108-
109-
@app.callback(Output('output', 'children'),
110-
[Input('upload', 'contents')])
111-
def update_output(contents):
112-
if contents is not None:
113-
content_type, content_string = contents.split(',')
114-
if 'csv' in filepath:
115-
df = pd.read_csv(io.StringIO(base64.b64decode(
116-
content_string).decode('utf-8')))
117-
return html.Div([
118-
DataTable(
119-
data=df.to_dict('records'),
120-
columns=[{'id': i} for i in ['city', 'country']]),
121-
html.Hr(),
122-
html.Div('Raw Content'),
123-
html.Pre(contents, style=pre_style)
124-
])
125-
elif 'xls' in filepath:
126-
df = pd.read_excel(io.BytesIO(base64.b64decode(
127-
content_string)))
128-
return html.Div([
129-
DataTable(
130-
data=df.to_dict('records'),
131-
columns=[{'id': i} for i in ['city', 'country']]),
132-
html.Hr(),
133-
html.Div('Raw Content'),
134-
html.Pre(contents, style=pre_style)
135-
])
136-
elif 'image' in content_type:
137-
return html.Div([
138-
html.Img(src=contents),
139-
html.Hr(),
140-
html.Div('Raw Content'),
141-
html.Pre(contents, style=pre_style)
142-
])
143-
else:
144-
return html.Div([
145-
html.Hr(),
146-
html.Div('Raw Content'),
147-
html.Pre(contents, style=pre_style)
148-
])
149-
150-
self.startServer(app)
151-
152-
try:
153-
self.wait_for_element_by_css_selector('#waitfor')
154-
except Exception as e:
155-
print(self.wait_for_element_by_css_selector(
156-
'#_dash-app-content').get_attribute('innerHTML'))
157-
raise e
158-
159-
upload_div = self.wait_for_element_by_css_selector(
160-
'#upload-div input[type=file]')
161-
162-
upload_div.send_keys(filepath)
163-
time.sleep(5)
164-
self.snapshot(filename)
165-
166-
def test_upload_csv(self):
167-
self.create_upload_component_content_types_test('utf8.csv')
168-
169-
def test_upload_xlsx(self):
170-
self.create_upload_component_content_types_test('utf8.xlsx')
171-
172-
def test_upload_png(self):
173-
self.create_upload_component_content_types_test('dash-logo-stripe.png')
174-
175-
def test_upload_svg(self):
176-
self.create_upload_component_content_types_test('dash-logo-stripe.svg')
177-
178-
def test_upload_gallery(self):
179-
app = dash.Dash(__name__)
180-
app.layout = html.Div([
181-
html.Div(id='waitfor'),
182-
html.Label('Empty'),
183-
dcc.Upload(),
184-
185-
html.Label('Button'),
186-
dcc.Upload(html.Button('Upload File')),
187-
188-
html.Label('Text'),
189-
dcc.Upload('Upload File'),
190-
191-
html.Label('Link'),
192-
dcc.Upload(html.A('Upload File')),
193-
194-
html.Label('Style'),
195-
dcc.Upload([
196-
'Drag and Drop or ',
197-
html.A('Select a File')
198-
], style={
199-
'width': '100%',
200-
'height': '60px',
201-
'lineHeight': '60px',
202-
'borderWidth': '1px',
203-
'borderStyle': 'dashed',
204-
'borderRadius': '5px',
205-
'textAlign': 'center'
206-
})
207-
])
208-
self.startServer(app)
209-
210-
try:
211-
self.wait_for_element_by_css_selector('#waitfor')
212-
except Exception as e:
213-
print(self.wait_for_element_by_css_selector(
214-
'#_dash-app-content').get_attribute('innerHTML'))
215-
raise e
216-
217-
self.snapshot('test_upload_gallery')
74+
# def create_upload_component_content_types_test(self, filename):
75+
# app = dash.Dash(__name__)
76+
77+
# filepath = os.path.join(os.getcwd(), 'test', 'upload-assets', filename)
78+
79+
# pre_style = {
80+
# 'whiteSpace': 'pre-wrap',
81+
# 'wordBreak': 'break-all'
82+
# }
83+
84+
# app.layout = html.Div([
85+
# html.Div(filepath, id='waitfor'),
86+
# html.Div(
87+
# id='upload-div',
88+
# children=dcc.Upload(
89+
# id='upload',
90+
# children=html.Div([
91+
# 'Drag and Drop or ',
92+
# html.A('Select a File')
93+
# ]),
94+
# style={
95+
# 'width': '100%',
96+
# 'height': '60px',
97+
# 'lineHeight': '60px',
98+
# 'borderWidth': '1px',
99+
# 'borderStyle': 'dashed',
100+
# 'borderRadius': '5px',
101+
# 'textAlign': 'center'
102+
# }
103+
# )
104+
# ),
105+
# html.Div(id='output'),
106+
# html.Div(DataTable(data=[{}]), style={'display': 'none'})
107+
# ])
108+
109+
# @app.callback(Output('output', 'children'),
110+
# [Input('upload', 'contents')])
111+
# def update_output(contents):
112+
# if contents is not None:
113+
# content_type, content_string = contents.split(',')
114+
# if 'csv' in filepath:
115+
# df = pd.read_csv(io.StringIO(base64.b64decode(
116+
# content_string).decode('utf-8')))
117+
# return html.Div([
118+
# DataTable(
119+
# data=df.to_dict('records'),
120+
# columns=[{'id': i} for i in ['city', 'country']]),
121+
# html.Hr(),
122+
# html.Div('Raw Content'),
123+
# html.Pre(contents, style=pre_style)
124+
# ])
125+
# elif 'xls' in filepath:
126+
# df = pd.read_excel(io.BytesIO(base64.b64decode(
127+
# content_string)))
128+
# return html.Div([
129+
# DataTable(
130+
# data=df.to_dict('records'),
131+
# columns=[{'id': i} for i in ['city', 'country']]),
132+
# html.Hr(),
133+
# html.Div('Raw Content'),
134+
# html.Pre(contents, style=pre_style)
135+
# ])
136+
# elif 'image' in content_type:
137+
# return html.Div([
138+
# html.Img(src=contents),
139+
# html.Hr(),
140+
# html.Div('Raw Content'),
141+
# html.Pre(contents, style=pre_style)
142+
# ])
143+
# else:
144+
# return html.Div([
145+
# html.Hr(),
146+
# html.Div('Raw Content'),
147+
# html.Pre(contents, style=pre_style)
148+
# ])
149+
150+
# self.startServer(app)
151+
152+
# try:
153+
# self.wait_for_element_by_css_selector('#waitfor')
154+
# except Exception as e:
155+
# print(self.wait_for_element_by_css_selector(
156+
# '#_dash-app-content').get_attribute('innerHTML'))
157+
# raise e
158+
159+
# upload_div = self.wait_for_element_by_css_selector(
160+
# '#upload-div input[type=file]')
161+
162+
# upload_div.send_keys(filepath)
163+
# time.sleep(5)
164+
# self.snapshot(filename)
165+
166+
# def test_upload_csv(self):
167+
# self.create_upload_component_content_types_test('utf8.csv')
168+
169+
# def test_upload_xlsx(self):
170+
# self.create_upload_component_content_types_test('utf8.xlsx')
171+
172+
# def test_upload_png(self):
173+
# self.create_upload_component_content_types_test('dash-logo-stripe.png')
174+
175+
# def test_upload_svg(self):
176+
# self.create_upload_component_content_types_test('dash-logo-stripe.svg')
177+
178+
# def test_upload_gallery(self):
179+
# app = dash.Dash(__name__)
180+
# app.layout = html.Div([
181+
# html.Div(id='waitfor'),
182+
# html.Label('Empty'),
183+
# dcc.Upload(),
184+
185+
# html.Label('Button'),
186+
# dcc.Upload(html.Button('Upload File')),
187+
188+
# html.Label('Text'),
189+
# dcc.Upload('Upload File'),
190+
191+
# html.Label('Link'),
192+
# dcc.Upload(html.A('Upload File')),
193+
194+
# html.Label('Style'),
195+
# dcc.Upload([
196+
# 'Drag and Drop or ',
197+
# html.A('Select a File')
198+
# ], style={
199+
# 'width': '100%',
200+
# 'height': '60px',
201+
# 'lineHeight': '60px',
202+
# 'borderWidth': '1px',
203+
# 'borderStyle': 'dashed',
204+
# 'borderRadius': '5px',
205+
# 'textAlign': 'center'
206+
# })
207+
# ])
208+
# self.startServer(app)
209+
210+
# try:
211+
# self.wait_for_element_by_css_selector('#waitfor')
212+
# except Exception as e:
213+
# print(self.wait_for_element_by_css_selector(
214+
# '#_dash-app-content').get_attribute('innerHTML'))
215+
# raise e
216+
217+
# self.snapshot('test_upload_gallery')
218218

219219
def test_loading_component_initialization(self):
220220
lock = Lock()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)