コード例 #1
0
def ingest():
    """
    Ingest institutions.
    """

    Institution.ingest_usa()
    Institution.ingest_world()
コード例 #2
0
def ingest():

    """
    Ingest institutions.
    """

    Institution.ingest_usa()
    Institution.ingest_world()
コード例 #3
0
def test_block_empty_urls():
    """
    Don't ingest rows with empty URLs.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/empty_urls.csv',
    )

    assert Institution.select().count() == 1

    assert Institution.select().where(Institution.name == 'inst1')
コード例 #4
0
def test_skip_us_rows():
    """
    "US" institutions should be ignored.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/skip_us_rows.csv',
    )

    assert Institution.select().count() == 2

    assert Institution.select().where(Institution.name == 'inst1')
    assert Institution.select().where(Institution.name == 'inst2')
    assert not Institution.select().where(Institution.name == 'inst3')
コード例 #5
0
def test_strip_values():
    """
    Field values should be stripped.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/strip_values.csv',
    )

    assert Institution.select().where(
        Institution.name == 'inst',
        Institution.url == 'http://inst.edu',
        Institution.state == None,
        Institution.country == 'AU',
    )
コード例 #6
0
def test_skip_us_rows():

    """
    "US" institutions should be ignored.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/skip_us_rows.csv',
    )

    assert Institution.select().count() == 2

    assert Institution.select().where(Institution.name=='inst1')
    assert Institution.select().where(Institution.name=='inst2')
    assert not Institution.select().where(Institution.name=='inst3')
コード例 #7
0
def test_strip_values():

    """
    Field values should be stripped.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/strip_values.csv',
    )

    assert Institution.select().where(
        Institution.name=='inst',
        Institution.url=='http://inst.edu',
        Institution.domain=='inst.edu',
        Institution.state==None,
        Institution.country=='AU',
    )
コード例 #8
0
def test_insert_rows():
    """
    Institution.ingest_world() should load rows.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/insert_rows.csv',
    )

    assert Institution.select().count() == 3

    for i in map(str, [1, 2, 3]):

        assert Institution.select().where(
            Institution.name == 'inst{0}'.format(i),
            Institution.url == 'http://inst{0}.edu'.format(i),
            Institution.state == None,
            Institution.country == 'C{0}'.format(i),
        )
コード例 #9
0
def test_insert_rows():

    """
    Institution.ingest_world() should load rows.
    """

    Institution.ingest_world(
        'osp.test.institutions.models.institution',
        'fixtures/ingest_world/insert_rows.csv',
    )

    assert Institution.select().count() == 3

    for i in map(str, [1, 2, 3]):

        assert Institution.select().where(
            Institution.name=='inst{0}'.format(i),
            Institution.url=='http://inst{0}.edu'.format(i),
            Institution.domain=='inst{0}.edu'.format(i),
            Institution.state==None,
            Institution.country=='C{0}'.format(i),
        )