mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
notify-api-412 use black to enforce python coding style
This commit is contained in:
@@ -7,36 +7,43 @@ from app.models.spreadsheet import Spreadsheet
|
||||
|
||||
|
||||
def test_can_create_spreadsheet_from_large_excel_file():
|
||||
with open(str(Path.cwd() / 'tests' / 'spreadsheet_files' / 'excel 2007.xlsx'), 'rb') as xl:
|
||||
ret = Spreadsheet.from_file(xl, filename='xl.xlsx')
|
||||
with open(
|
||||
str(Path.cwd() / "tests" / "spreadsheet_files" / "excel 2007.xlsx"), "rb"
|
||||
) as xl:
|
||||
ret = Spreadsheet.from_file(xl, filename="xl.xlsx")
|
||||
assert ret.as_csv_data
|
||||
|
||||
|
||||
def test_can_create_spreadsheet_from_dict():
|
||||
assert Spreadsheet.from_dict(OrderedDict(
|
||||
foo='bar',
|
||||
name='Jane',
|
||||
)).as_csv_data == (
|
||||
"foo,name\r\n"
|
||||
"bar,Jane\r\n"
|
||||
)
|
||||
assert Spreadsheet.from_dict(
|
||||
OrderedDict(
|
||||
foo="bar",
|
||||
name="Jane",
|
||||
)
|
||||
).as_csv_data == ("foo,name\r\n" "bar,Jane\r\n")
|
||||
|
||||
|
||||
def test_can_create_spreadsheet_from_dict_with_filename():
|
||||
assert Spreadsheet.from_dict({}, filename='empty.csv').as_dict['file_name'] == "empty.csv"
|
||||
assert (
|
||||
Spreadsheet.from_dict({}, filename="empty.csv").as_dict["file_name"]
|
||||
== "empty.csv"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('args, kwargs', (
|
||||
@pytest.mark.parametrize(
|
||||
"args, kwargs",
|
||||
(
|
||||
('hello', ['hello']),
|
||||
{},
|
||||
(
|
||||
("hello", ["hello"]),
|
||||
{},
|
||||
),
|
||||
((), {"csv_data": "hello", "rows": ["hello"]}),
|
||||
),
|
||||
(
|
||||
(),
|
||||
{'csv_data': 'hello', 'rows': ['hello']}
|
||||
),
|
||||
))
|
||||
)
|
||||
def test_spreadsheet_checks_for_bad_arguments(args, kwargs):
|
||||
with pytest.raises(TypeError) as exception:
|
||||
Spreadsheet(*args, **kwargs)
|
||||
assert str(exception.value) == 'Spreadsheet must be created from either rows or CSV data'
|
||||
assert (
|
||||
str(exception.value)
|
||||
== "Spreadsheet must be created from either rows or CSV data"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user