Esempio n. 1
0
def test_table_length():

    sheet = dtocean_dummy.Spreadsheet()
    array = sheet._get_random_array(10)
    sheet._array_2_df(array)

    assert len(sheet.table) == 10
Esempio n. 2
0
def test_table_cumsum_total():
    '''Check that the cumulative sum in the pandas table is OK'''

    sheet = dtocean_dummy.Spreadsheet()
    array = sheet._get_random_array(10)
    sheet._array_2_df(array)
    sheet._add_cumsum()

    cumsum = sheet.table['Cumulative']

    assert cumsum.irow(-1) == sum(array)
Esempio n. 3
0
def test_table_cumsum_length():
    '''Check that the length of the cumulative sum is OK'''

    sheet = dtocean_dummy.Spreadsheet()
    array = sheet._get_random_array(10)
    sheet._array_2_df(array)
    sheet._add_cumsum()

    cumsum = sheet.table['Cumulative']

    assert len(cumsum) == 10
Esempio n. 4
0
def test_create_xls(tmpdir):
    '''Test if excel file is written'''

    locd = tmpdir.mkdir("sub")
    p = locd.join("test.xls")

    sheet = dtocean_dummy.Spreadsheet()
    sheet.make_table(10)
    sheet.write_xls(str(p))

    assert len(locd.listdir()) == 1
    assert os.path.basename(str(locd.listdir()[0])) == "test.xls"
Esempio n. 5
0
def test_spreadsheet_call(tmpdir):
    '''Test if Spreadsheet.call works for all file types'''

    locd = tmpdir.mkdir("sub")
    dirp = str(locd)

    sheet = dtocean_dummy.Spreadsheet()

    # Check the error for a bad file type
    filep = os.path.join(dirp, "test.docx")

    with pytest.raises(ValueError):
        sheet(10, filep, out_fmt='docx')

    for ftype in sheet._valid_formats:

        filep = os.path.join(dirp, "test.{}".format(ftype))

        sheet(10, filep, out_fmt=ftype)

    assert len(locd.listdir()) == len(sheet._valid_formats)
Esempio n. 6
0
def sheet():
    '''Share a Spreadsheet object'''
    return dtocean_dummy.Spreadsheet()