Skip to content
Snippets Groups Projects
Verified Commit c53fc452 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Moved scripting tests to webui

parent 973f4f79
Branches
No related tags found
No related merge requests found
File deleted
File deleted
File deleted
File deleted
Hi,  this line contains a unicode backspace. This causes a server error, when pandas_table_preview.py's output is serialized into XML.
\ No newline at end of file
# test header
# two lines
A1,B1,C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1,O1,P1,Q1,R1,S1,T1
A2,B2,C2,D2,E2,F2,G2,H2,I2,J2,K2,L2,M2,N2,O2,P2,Q2,R2,S2,T2
A3,B3,csvfile,D3,E3,F3,G3,H3,I3,J3,K3,L3,M3,N3,O3,P3,Q3,R3,S3,T3
A5,B5,C5,D5,E5,F5,G5,H5,I5,J5,K5,L5,M5,N5,O5,P5,Q5,R5,S5,T5
A6,B6,C6,D6,E6,F6,G6,H6,I6,J6,K6,L6,M6,N6,O6,P6,Q6,R6,S6,T6
A7,B7,csvfile,D7,E7,F7,G7,H7,I7,J7,K7,L7,M7,N7,O7,P7,Q7,R7,S7,T7
A8,B8,C8,D8,E8,F8,G8,H8,I8,J8,K8,L8,M8,N8,O8,P8,Q8,R8,S8,T8
A9,B9,C9,D9,E9,F9,G9,H9,I9,J9,K9,L9,M9,N9,O9,P9,Q9,R9,S9,T9
A10,B10,C10,D10,E10,F10,G10,H10,I10,J10,K10,L10,M10,N10,O10,P10,Q10,R10,S10,T10
A11,B11,C11,D11,E11,F11,G11,H11,I11,J11,K11,L11,M11,N11,O11,P11,Q11,R11,S11,T11
# test header
# two lines
A1 B1 C1 D1 E1 F1 G1 H1 I1 J1 K1 L1 M1 N1 O1 P1 Q1 R1 S1 T1
A2 B2 C2 D2 E2 F2 G2 H2 I2 J2 K2 L2 M2 N2 O2 P2 Q2 R2 S2 T2
A3 B3 csvfile D3 E3 F3 G3 H3 I3 J3 K3 L3 M3 N3 O3 P3 Q3 R3 S3 T3
A5 B5 C5 D5 E5 F5 G5 H5 I5 J5 K5 L5 M5 N5 O5 P5 Q5 R5 S5 T5
A6 B6 C6 D6 E6 F6 G6 H6 I6 J6 K6 L6 M6 N6 O6 P6 Q6 R6 S6 T6
A7 B7 tsvfile D7 E7 F7 G7 H7 I7 J7 K7 L7 M7 N7 O7 P7 Q7 R7 S7 T7
A8 B8 C8 D8 E8 F8 G8 H8 I8 J8 K8 L8 M8 N8 O8 P8 Q8 R8 S8 T8
A9 B9 C9 D9 E9 F9 G9 H9 I9 J9 K9 L9 M9 N9 O9 P9 Q9 R9 S9 T9
A10 B10 C10 D10 E10 F10 G10 H10 I10 J10 K10 L10 M10 N10 O10 P10 Q10 R10 S10 T10
A11 B11 C11 D11 E11 F11 G11 H11 I11 J11 K11 L11 M11 N11 O11 P11 Q11 R11 S11 T11
File deleted
File deleted
# as it seems all these characters are escaped correctly.
"![Alt text](url/to/image)","%3C","&lt","<","&LT","<","&#60","&#060","&#0060","&#00060"
"&#000060","&#0000060","<","<","<","<","<","<","&#x3c","&#x03c"
"&#x003c","&#x0003c","&#x00003c","&#x000003c","<","<","<","<","<","<"
"&#X3c","&#X03c","&#X003c","&#X0003c","&#X00003c","&#X000003c","<","<","<","<"
"<","<","&#x3C","&#x03C","&#x003C","&#x0003C","&#x00003C","&#x000003C","<","<"
"<","<","<","<","&#X3C","&#X03C","&#X003C","&#X0003C","&#X00003C","&#X000003C"
"<","<","<","<","<","<","\x3c","\x3C","\u003c","\u003C"
caosdb
caosadvancedtools
pandas
#!/usr/bin/env python3
# encoding: utf-8
#
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2020 Henrik tom Wörden <h.tomwoerden@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ** end header
#
import os
import unittest
import caosdb as db
from caosdb.common.models import _parse_single_xml_element
from lxml import etree
from pandas_table_preview import (MAXIMUMFILESIZE, create_table_preview,
ending_is_valid, read_file, size_is_ok)
class PreviewTest(unittest.TestCase):
def test_file_ending(self):
self.assertFalse(ending_is_valid("/this/is/no/xls.lol"))
self.assertFalse(ending_is_valid("xls.lol"))
self.assertFalse(ending_is_valid("ag.xls.lol"))
assert ending_is_valid("/this/is/a/lol.xls")
assert ending_is_valid("/this/is/a/lol.csv")
assert ending_is_valid("/this/is/a/lol.cSv")
assert ending_is_valid("/this/is/a/lol.CSV")
assert ending_is_valid("lol.CSV")
def test_file_size(self):
entity_xml = ('<File id="1234" name="SomeFile" '
'path="/this/path.tsv" size="{size}"></File>')
small = _parse_single_xml_element(
etree.fromstring(entity_xml.format(size="20000")))
assert size_is_ok(small)
large = _parse_single_xml_element(
etree.fromstring(entity_xml.format(
size=str(int(MAXIMUMFILESIZE+1)))))
assert not size_is_ok(large)
def test_output(self):
files = [os.path.join(os.path.dirname(__file__), "data", f)
for f in ["test.csv", "test.tsv", "test.xls", "test.xlsx"]]
for fi in files:
table = read_file(fi, ftype="."+fi.split(".")[-1])
searchkey = fi.split(".")[-1]+"file"
print(table)
assert (table == searchkey).any(axis=None)
badfiles = [os.path.join(os.path.dirname(__file__), "data", f)
for f in ["bad.csv", "bad.tsv", "bad.xls", "bad.xlsx"]]
for bfi in badfiles:
self.assertRaises(ValueError, read_file,
bfi, "."+bfi.split(".")[-1])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment