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

        >>> browser = Browser('manager', 'schooltool')

    We'll add some demo fields to test importing demos.

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Demographics').click()
        >>> browser.getLink('New Date Field').click()
        >>> browser.getControl("Title").value = 'Date Demo'
        >>> browser.getControl("ID").value = 'date_demo'
        >>> browser.getControl(name="form.widgets.required").value = ["false"]
        >>> browser.getControl('Add').click()

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Demographics').click()
        >>> browser.getLink('New Yes/No Field').click()
        >>> browser.getControl("Title").value = 'Bool Demo'
        >>> browser.getControl("ID").value = 'bool_demo'
        >>> browser.getControl(name="form.widgets.required").value = ["false"]
        >>> browser.getControl('Add').click()

    Now we'll go ahead with the import.

        >>> 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']")

No data provided

    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]

#### Address

1 First Street, Line 2, NY, NY, NY, 10101

#### Email

email

#### Phones

home (Home phone), work (Work phone), 111-111 (Mobile phone)

#### Spoken Languages

english

>>> browser.printQuery("//div[@class='person-info']/fieldset")

## Parent, Parent One

(View Details)

#### Address

1 First Street, Line 2, NY, NY, NY, 10101

#### Email

email

#### Phones

home (Home phone), work (Work phone), 333-3333 (Mobile phone)

#### Spoken Languages

english

## Parent, Parent Two

(View Details)

#### Address

1 First Street

#### Phones

444-4444 (Mobile phone)

## Sibling, Sibling One

(View Details)

#### Address

1 First Street

#### Phones

555-5555 (Mobile phone)

        >>> 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]

#### Address

1 First Street

#### Phones

222-2222 (Mobile phone)

>>> browser.printQuery("//div[@class='person-info']/fieldset")

## Guardian, Guardian One

(View Details)

#### Address

2 Second Street

#### Phones

666-6666 (Mobile phone)

    Let's confirm the demo imports worked.  We just have one date for the manager
    user and the four possible booleans, two actual booleans in the xls document
    and two represented as strings but still valid.  We'll test a fifth person
    whose boolean demo is not at all set to show that missing boolean demos that
    are not required will keep the object's value for that field as None.

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'manager'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Manager').click()
        >>> browser.getLink('Edit').click()
        >>> browser.queryHTML('//input[@name="form.widgets.date_demo"]/@value')
        ['2001-01-01']
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> 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('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> 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('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'student002'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Sherm').click()
        >>> browser.getLink('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'student003'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Piotr').click()
        >>> browser.getLink('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
    We have 4 terms:

        >>> browser.getLink('2006-2008').click()
        >>> browser.printQuery("id('content-body')/form//div/a")
2006 Fall (Sep 1, 2006 — Jan 26, 2007) 2007 Spring (Jan 29, 2007 — Jun 15, 2007) 2007 Fall (Sep 1, 2007 — Jan 27, 2008) 2008 Spring
                (Jan 28, 2008
                —
                Jun 20, 2008)

    Some sections:

        >>> browser.getLink('2006 Fall').click()
        >>> browser.getLink('Sections').click()
        >>> browser.printQuery("id('content-body')//table/tr[2]/td")
Art A Art A (0) Isabel Walsh (45 Students)
        >>> 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")
Andy Lea David Krzysztof Eleanor Matthew Jorge Leonie Philippa Ed Jean Vanessa Sean Mathias Tobias Anna Sophie Agnieszka Pip Ellie Caitlin Louise Fabian Jozef Anthony Sem Alexis Ryan Kayleigh Jose Rob One Carolina Georgina Lisa Manuel Al Daniel Ricky Betty Drew Diego Georgina Claudia Joe
    Let's prove that it's ok to re-import the sample data:

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('XLS Import').click()
        >>> 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()

    Let's check the data again. 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]

#### Address

1 First Street, Line 2, NY, NY, NY, 10101

#### Email

email

#### Phones

home (Home phone), work (Work phone), 111-111 (Mobile phone)

#### Spoken Languages

english

>>> browser.printQuery("//div[@class='person-info']/fieldset")

## Parent, Parent One

(View Details)

#### Address

1 First Street, Line 2, NY, NY, NY, 10101

#### Email

email

#### Phones

home (Home phone), work (Work phone), 333-3333 (Mobile phone)

#### Spoken Languages

english

## Parent, Parent Two

(View Details)

#### Address

1 First Street

#### Phones

444-4444 (Mobile phone)

## Sibling, Sibling One

(View Details)

#### Address

1 First Street

#### Phones

555-5555 (Mobile phone)

        >>> 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]

#### Address

1 First Street

#### Phones

222-2222 (Mobile phone)

>>> browser.printQuery("//div[@class='person-info']/fieldset")

## Guardian, Guardian One

(View Details)

#### Address

2 Second Street

#### Phones

666-6666 (Mobile phone)

    Let's confirm the demo re-imports worked.

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'manager'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Manager').click()
        >>> browser.getLink('Edit').click()
        >>> browser.queryHTML('//input[@name="form.widgets.date_demo"]/@value')
        ['2001-01-01']
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> 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('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> 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('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'student002'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Sherm').click()
        >>> browser.getLink('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Persons').click()
        >>> browser.getControl(name="SEARCH_TITLE").value = 'student003'
        >>> browser.getControl('Find Now').click()
        >>> browser.getLink('Piotr').click()
        >>> browser.getLink('Edit').click()
        >>> browser.printQuery('//input[@name="form.widgets.bool_demo"]')
    We have 4 terms:

        >>> browser.getLink('2006-2008').click()
        >>> browser.printQuery("id('content-body')/form//div/a")
2006 Fall (Sep 1, 2006 — Jan 26, 2007) 2007 Spring (Jan 29, 2007 — Jun 15, 2007) 2007 Fall (Sep 1, 2007 — Jan 27, 2008) 2008 Spring
                (Jan 28, 2008
                —
                Jun 20, 2008)

    Some sections:

        >>> browser.getLink('2006 Fall').click()
        >>> browser.getLink('Sections').click()
        >>> browser.printQuery("id('content-body')//table/tr[2]/td")
Art A Art A (0) Isabel Walsh (45 Students)
        >>> 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")
Andy Lea David Krzysztof Eleanor Matthew Jorge Leonie Philippa Ed Jean Vanessa Sean Mathias Tobias Anna Sophie Agnieszka Pip Ellie Caitlin Louise Fabian Jozef Anthony Sem Alexis Ryan Kayleigh Jose Rob One Carolina Georgina Lisa Manuel Al Daniel Ricky Betty Drew Diego Georgina Claudia Joe