Ejemplo n.º 1
0
def _do_merge_calendar(calendar_file, ntfs_file, output_file):
    with ZipFile(calendar_file,
                 'r') as calendars_zip, ZipFile(ntfs_file, 'r') as ntfs_zip:
        grid_calendar_data = GridCalendarData()
        grid_calendar_data.load_zips(calendars_zip, ntfs_zip)
        new_ntfs_zip = calendar_handler.merge_calendars_ntfs(
            grid_calendar_data, ntfs_zip)
        calendar_handler.save_zip_as_file(new_ntfs_zip, output_file)
Ejemplo n.º 2
0
def test_merge_ntfs_without_calendar_file(ntfs_zip):
    grid_calendar_data = GridCalendarData()
    new_ntfs_zip = calendar_handler.merge_calendars_ntfs(grid_calendar_data, ntfs_zip)

    assert calendar_handler.GRID_CALENDARS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_PERIODS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_CALENDAR_REL_LINE not in new_ntfs_zip.namelist()

    # we want to find all the non calendar file from the input ntfs in the newly generated one
    assert set(ntfs_zip.namelist()) == {s for s in new_ntfs_zip.namelist() if not s.startswith('grid_')}
Ejemplo n.º 3
0
def test_merge_ntfs_no_calendar_file(ntfs_zip):
    calendars_zip = ZipFile(BytesIO(), 'a', ZIP_DEFLATED, False)
    calendars_zip.writestr('foo.txt', 'foo')
    grid_calendar_data = GridCalendarData()
    grid_calendar_data.load_zips(calendars_zip, ntfs_zip)
    new_ntfs_zip = calendar_handler.merge_calendars_ntfs(grid_calendar_data, ntfs_zip)

    assert calendar_handler.GRID_CALENDARS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_PERIODS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_CALENDAR_REL_LINE not in new_ntfs_zip.namelist()

    # we want to find all the non calendar file from the input ntfs in the newly generated one
    assert set(ntfs_zip.namelist()) == {s for s in new_ntfs_zip.namelist() if not s.startswith('grid_')}
Ejemplo n.º 4
0
def test_merge_ntfs_without_calendar_file(ntfs_zip):
    grid_calendar_data = GridCalendarData()
    new_ntfs_zip = calendar_handler.merge_calendars_ntfs(
        grid_calendar_data, ntfs_zip)

    assert calendar_handler.GRID_CALENDARS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_PERIODS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_CALENDAR_REL_LINE not in new_ntfs_zip.namelist(
    )

    # we want to find all the non calendar file from the input ntfs in the newly generated one
    assert set(ntfs_zip.namelist()) == {
        s
        for s in new_ntfs_zip.namelist() if not s.startswith('grid_')
    }
Ejemplo n.º 5
0
def test_merge_ntfs_no_calendar_file(ntfs_zip):
    calendars_zip = ZipFile(BytesIO(), 'a', ZIP_DEFLATED, False)
    calendars_zip.writestr('foo.txt', 'foo')
    grid_calendar_data = GridCalendarData()
    grid_calendar_data.load_zips(calendars_zip, ntfs_zip)
    new_ntfs_zip = calendar_handler.merge_calendars_ntfs(
        grid_calendar_data, ntfs_zip)

    assert calendar_handler.GRID_CALENDARS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_PERIODS not in new_ntfs_zip.namelist()
    assert calendar_handler.GRID_CALENDAR_REL_LINE not in new_ntfs_zip.namelist(
    )

    # we want to find all the non calendar file from the input ntfs in the newly generated one
    assert set(ntfs_zip.namelist()) == {
        s
        for s in new_ntfs_zip.namelist() if not s.startswith('grid_')
    }
Ejemplo n.º 6
0
def _do_merge_calendar(calendar_file, ntfs_file, output_file):
    with ZipFile(calendar_file, 'r') as calendars_zip, ZipFile(ntfs_file, 'r') as ntfs_zip:
        grid_calendar_data = GridCalendarData()
        grid_calendar_data.load_zips(calendars_zip, ntfs_zip)
        new_ntfs_zip = calendar_handler.merge_calendars_ntfs(grid_calendar_data, ntfs_zip)
        calendar_handler.save_zip_as_file(new_ntfs_zip, output_file)