Tests for errant import data
----------------------------

This file has examples of bad data for the School Years sheet:

    >>> browser = Browser('manager', 'schooltool')
    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_years.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">School Years C2 has no date in it</p>
    <p class="error">School Years D2 has no date in it</p>
    <p class="error">School Years D3 end date cannot be before start date</p>
    <p class="error">School Years C5 start date overlaps another year</p>
    <p class="error">School Years D6 end date overlaps another year</p>
    <p class="error">School Years A7 not unicode or ascii string</p>
    <p class="error">School Years B7 not unicode or ascii string</p>

This file has examples of bad data for the Terms sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_terms.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Terms B2 missing required text</p>
    <p class="error">Terms C2 missing required text</p>
    <p class="error">Terms D2 has no date in it</p>
    <p class="error">Terms E2 has no date in it</p>
    <p class="error">Terms A3 not unicode or ascii string</p>
    <p class="error">Terms A4 invalid school year</p>
    <p class="error">Terms E5 end date cannot be before start date</p>
    <p class="error">Terms D6 start date before start of school year</p>
    <p class="error">Terms E7 end date after end of school year</p>
    <p class="error">Terms D10 start date overlaps another term</p>
    <p class="error">Terms E11 end date overlaps another term</p>
    <p class="error">Terms A15 has no date in it</p>
    <p class="error">Terms B16 has no date in it</p>
    <p class="error">Terms E17 end date cannot be before start date</p>

This file has examples of bad data for the School Timetables sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_timetables.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">School Timetables B1 missing required text</p>
    <p class="error">School Timetables B2 missing required text</p>
    <p class="error">School Timetables B3 missing required text</p>
    <p class="error">School Timetables B4 missing required text</p>
    <p class="error">School Timetables B6 not unicode or ascii string</p>
    <p class="error">School Timetables B7 not unicode or ascii string</p>
    <p class="error">School Timetables B8 not unicode or ascii string</p>
    <p class="error">School Timetables B9 not unicode or ascii string</p>
    <p class="error">School Timetables B13 invalid school year</p>
    <p class="error">School Timetables B14 is not a valid timetable model</p>
    <p class="error">Schema has no day templates in A21</p>
    <p class="error">School Timetables A27 not unicode or ascii string</p>
    <p class="error">School Timetables B27 is not a valid time range</p>
    <p class="error">School Timetables A29 is the same day id as another in this timetable</p>
    <p class="error">School Timetables A40 is not defined in the 'Day Templates' section</p>
    <p class="error">School Timetables A42 is the same day id as another in this timetable</p>
    <p class="error">School Timetables E42 is the same period id as another in this day</p>
    <p class="error">School Timetables I42 is the same homeroom period id as another in this day</p>
    <p class="error">School Timetables A50 is not a valid integer</p>
    <p class="error">School Timetables A51 is not a valid integer</p>
    <p class="error">School Timetables A52 is not a valid weekday number (0-6)</p>

This file has examples of bad data for the Resouces sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_resources.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Resources B2 missing required text</p>
    <p class="error">Resources C2 missing required text</p>
    <p class="error">Resources B3 must be either 'Location' or 'Resource'</p>

This file has examples of bad data for the Persons sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_persons.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Persons B2 not unicode or ascii string</p>
    <p class="error">Persons C2 missing required text</p>
    <p class="error">Persons D2 not unicode or ascii string</p>
    <p class="error">Persons E2 missing required text</p>
    <p class="error">Persons F2 not unicode or ascii string</p>
    <p class="error">Persons G2 not unicode or ascii string</p>
    <p class="error">Persons I2 not unicode or ascii string</p>
    <p class="error">Persons J2 not unicode or ascii string</p>
    <p class="error">Persons K2 not unicode or ascii string</p>
    <p class="error">Persons L2 not unicode or ascii string</p>
    <p class="error">Persons M2 not unicode or ascii string</p>
    <p class="error">Persons N2 not unicode or ascii string</p>
    <p class="error">Persons O2 not unicode or ascii string</p>
    <p class="error">Persons C3 not unicode or ascii string</p>
    <p class="error">Persons E3 not unicode or ascii string</p>
    <p class="error">Persons A4 Username cannot contain non-ascii characters: gr...ta</p>
    <p class="error">Persons A6 not unicode or ascii string</p>

This file has examples of bad data for the Courses sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_courses.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Courses B2 missing required text</p>
    <p class="error">Courses C2 missing required text</p>
    <p class="error">Courses A3 not unicode or ascii string</p>
    <p class="error">Courses B3 not unicode or ascii string</p>
    <p class="error">Courses C3 not unicode or ascii string</p>
    <p class="error">Courses D3 not unicode or ascii string</p>
    <p class="error">Courses A4 invalid school year</p>

This file has examples of bad data for the Sections sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_sections.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Sections 1 B1 missing required text</p>
    <p class="error">Sections 1 D1 missing required text</p>
    <p class="error">Sections_2 B1 not unicode or ascii string</p>
    <p class="error">Sections_2 D1 not unicode or ascii string</p>
    <p class="error">Sections_3 B1 invalid school year</p>
    <p class="error">Sections_4 D1 is not a valid term in the given school year</p>
    <p class="error">Sections_5 A11 not unicode or ascii string</p>
    <p class="error">Sections_5 A12 is not a valid username</p>
    <p class="error">Sections_5 A16 not unicode or ascii string</p>
    <p class="error">Sections_5 A17 is not a valid username</p>
    <p class="error">Sections_5 A22 not unicode or ascii string</p>
    <p class="error">Sections_5 B22 not unicode or ascii string</p>
    <p class="error">Sections_5 C22 not unicode or ascii string</p>
    <p class="error">Sections_5 A23 is not a valid day id for the given schema</p>
    <p class="error">Sections_5 C23 is not a valid resource id</p>
    <p class="error">Sections_5 B24 is not a valid period id for the given day</p>

This file has examples of bad data for the Groups sheet:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()
    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'errant_groups.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">Groups B1 missing required text</p>
    <p class="error">Groups B2 missing required text</p>
    <p class="error">Groups B3 missing required text</p>
    <p class="error">Groups B6 not unicode or ascii string</p>
    <p class="error">Groups B7 not unicode or ascii string</p>
    <p class="error">Groups B8 not unicode or ascii string</p>
    <p class="error">Groups B9 not unicode or ascii string</p>
    <p class="error">Groups A11 invalid school year</p>
    <p class="error">Groups A22 not unicode or ascii string</p>
    <p class="error">Groups A23 is not a valid username</p>

