Test for sample data import
---------------------------

    >>> browser = Browser('manager', 'schooltool')
    >>> browser.getLink('Manage').click()
    >>> browser.getLink('XLS Import').click()

Click the submit button without selecting a file:

    >>> browser.getControl('Submit').click()
    >>> browser.printQuery("//p[@class='error']")
    <p class="error">No data provided</p>

Let's import a subset of the sample data:

    >>> import pkg_resources
    >>> browser.getControl('XLS File').add_file(
    ...     pkg_resources.resource_stream('schooltool.export.ftests', 'test_data.xls'),
    ...     'application/excel',
    ...     'sample_data.xls')
    >>> browser.getControl('Submit').click()

There should be no errors:

    >>> browser.printQuery("//p[@class='error']")

Let's check the data. We have 2 students that have contacts:

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('Persons').click()
    >>> browser.getControl(name="SEARCH_TITLE").value = 'student000'
    >>> browser.getControl('Find Now').click()
    >>> browser.getLink('Florian').click()
    >>> browser.getLink('Contacts').click()
    >>> print browser.queryHTML("//div[@class='info-block']")[0]
    <div class="info-block">
      <h4>Address</h4>
      <p>1 First Street, Line 2, NY, NY, NY, 10101</p>
      <h4>Email</h4>
      <p>email</p>
      <h4>Phones</h4>
      <p>
        <span>home (Home phone)</span>,&#160;
        <span>work (Work phone)</span>,&#160;
        <span>111-111 (Mobile phone)</span>
      </p>
      <h4>Spoken Languages</h4>
      <p>english</p>
    </div>
    >>> browser.printQuery("//div[@class='person-info']/fieldset")
    <fieldset><div class="person-info">
        <h2> Parent, Parent One </h2>
        <a href="http://localhost/contacts/student000_parent1">(View Details)</a>
        <div class="info-block">
          <h4>Address</h4>
          <p>1 First Street, Line 2, NY, NY, NY, 10101</p>
          <h4>Email</h4>
          <p>email</p>
          <h4>Phones</h4>
          <p>
            <span>home (Home phone)</span>,&#160;
            <span>work (Work phone)</span>,&#160;
            <span>333-3333 (Mobile phone)</span>
          </p>
          <h4>Spoken Languages</h4>
          <p>english</p>
        </div>
    </div>
    </fieldset>
    <fieldset><div class="person-info">
        <h2> Parent, Parent Two </h2>
        <a href="http://localhost/contacts/student000_parent2">(View Details)</a>
        <div class="info-block">
          <h4>Address</h4>
          <p>1 First Street</p>
          <h4>Phones</h4>
          <p>
            <span>444-4444 (Mobile phone)</span>
          </p>
        </div>
    </div>
    </fieldset>
    <fieldset><div class="person-info">
        <h2> Sibling, Sibling One </h2>
        <a href="http://localhost/contacts/student000_sibling">(View Details)</a>
        <div class="info-block">
          <h4>Address</h4>
          <p>1 First Street</p>
          <h4>Phones</h4>
          <p>
            <span>555-5555 (Mobile phone)</span>
          </p>
        </div>
    </div>
    </fieldset>

    >>> browser.getLink('Manage').click()
    >>> browser.getLink('Persons').click()
    >>> browser.getControl(name="SEARCH_TITLE").value = 'student001'
    >>> browser.getControl('Find Now').click()
    >>> browser.getLink('Peg').click()
    >>> browser.getLink('Contacts').click()
    >>> print browser.queryHTML("//div[@class='info-block']")[0]
    <div class="info-block">
      <h4>Address</h4>
      <p>1 First Street</p>
      <h4>Phones</h4>
      <p>
        <span>222-2222 (Mobile phone)</span>
      </p>
    </div>
    >>> browser.printQuery("//div[@class='person-info']/fieldset")
    <fieldset><div class="person-info">
      <h2> Guardian, Guardian One </h2>
      <a href="http://localhost/contacts/student001_guardian">(View Details)</a>
      <div class="info-block">
        <h4>Address</h4>
        <p>2 Second Street</p>
        <h4>Phones</h4>
        <p>
          <span>666-6666 (Mobile phone)</span>
        </p>
      </div>
    </div>
    </fieldset>

We have 4 terms:

    >>> browser.getLink('2006-2008').click()
    >>> browser.printQuery("id('content-body')/form//div/a")
    <a href="http://localhost/schoolyears/2006-2008/2006-fall">2006 Fall</a>
            (Sep 1, 2006
            &#8212;
            Jan 26, 2007)
    <a href="http://localhost/schoolyears/2006-2008/2007-spring">2007 Spring</a>
            (Jan 29, 2007
            &#8212;
            Jun 15, 2007)
    <a href="http://localhost/schoolyears/2006-2008/2007-fall">2007 Fall</a>
            (Sep 1, 2007
            &#8212;
            Jan 27, 2008)
    <a href="http://localhost/schoolyears/2006-2008/2008-spring">2008 Spring</a>
            (Jan 28, 2008
            &#8212;
            Jun 20, 2008)

Some sections:

    >>> browser.getLink('2006 Fall').click()
    >>> browser.getLink('Sections').click()
    >>> browser.printQuery("id('content-body')//table/tr[2]/td")
    <td>
      <input type="checkbox" name="delete.art_a_2006-fall_teacher010_000" /></td>
    <td>
      <a href="http://localhost/schoolyears/2006-2008/courses/art_a">Art A</a>
    </td>
    <td>
      <a href="http://localhost/schoolyears/2006-2008/2006-fall/sections/art_a_2006-fall_teacher010_000">Art A (0)</a>
    </td>
    <td>
        <a href="http://localhost/persons/teacher010">Walsh, Isabel</a>
    </td>
    <td>
      <span class="hint">
        (44 <span>Students</span>)
      </span>
    </td>

    >>> len(browser.queryHTML("id('content-body')//table/tr"))
    26

And some students:

    >>> browser.getLink("Art A (0)", url="art_a_2006-fall_teacher010_000").click()
    >>> browser.printQuery("id('section-view')//table/tbody/tr/td[1]/a")
    <a href="http://localhost/persons/student228">Andy</a>
    <a href="http://localhost/persons/student994">Lea</a>
    <a href="http://localhost/persons/student978">David</a>
    <a href="http://localhost/persons/student036">Krzysztof</a>
    <a href="http://localhost/persons/student806">Eleanor</a>
    <a href="http://localhost/persons/student841">Matthew</a>
    <a href="http://localhost/persons/student694">Jorge</a>
    <a href="http://localhost/persons/student388">Leonie</a>
    <a href="http://localhost/persons/student603">Philippa</a>
    <a href="http://localhost/persons/student463">Ed</a>
    <a href="http://localhost/persons/student927">Jean</a>
    <a href="http://localhost/persons/student658">Vanessa</a>
    <a href="http://localhost/persons/student432">Sean</a>
    <a href="http://localhost/persons/student359">Mathias</a>
    <a href="http://localhost/persons/student596">Tobias</a>
    <a href="http://localhost/persons/student594">Anna</a>
    <a href="http://localhost/persons/student929">Sophie</a>
    <a href="http://localhost/persons/student145">Agnieszka</a>
    <a href="http://localhost/persons/student402">Pip</a>
    <a href="http://localhost/persons/student604">Ellie</a>
    <a href="http://localhost/persons/student699">Caitlin</a>
    <a href="http://localhost/persons/student838">Louise</a>
    <a href="http://localhost/persons/student047">Fabian</a>
    <a href="http://localhost/persons/student278">Jozef</a>
    <a href="http://localhost/persons/student898">Anthony</a>
    <a href="http://localhost/persons/student623">Sem</a>
    <a href="http://localhost/persons/student056">Alexis</a>
    <a href="http://localhost/persons/student808">Ryan</a>
    <a href="http://localhost/persons/student336">Kayleigh</a>
    <a href="http://localhost/persons/student067">Jose</a>
    <a href="http://localhost/persons/student684">Rob</a>
    <a href="http://localhost/persons/student185">Carolina</a>
    <a href="http://localhost/persons/student675">Georgina</a>
    <a href="http://localhost/persons/student752">Lisa</a>
    <a href="http://localhost/persons/student767">Manuel</a>
    <a href="http://localhost/persons/student552">Al</a>
    <a href="http://localhost/persons/student075">Daniel</a>
    <a href="http://localhost/persons/student554">Ricky</a>
    <a href="http://localhost/persons/student411">Betty</a>
    <a href="http://localhost/persons/student368">Drew</a>
    <a href="http://localhost/persons/student089">Diego</a>
    <a href="http://localhost/persons/student450">Georgina</a>
    <a href="http://localhost/persons/student198">Claudia</a>
    <a href="http://localhost/persons/student428">Joe</a>
