Esempio n. 1
0
def test_update():
    """Check database updating."""
    file_yaml = ".evn_test.yaml"
    with patch("sys.argv", ["py.test", "--schedule", file_yaml]):
        transfer_vn.run()
    with patch("sys.argv", ["py.test", "--update", file_yaml]):
        transfer_vn.run()
Esempio n. 2
0
def test_init():
    """Check --init parameter."""
    file_yaml = str(Path.home()) + "/" + ".evn_pytest.yaml"
    if Path(file_yaml).is_file():
        Path(file_yaml).unlink()
    with patch("sys.argv", ["py.test", "--init", ".evn_pytest.yaml"]):
        transfer_vn.run()
    assert Path(file_yaml).is_file()
    Path(file_yaml).unlink()
Esempio n. 3
0
def test_db_ops():
    """Check database management operations."""
    file_yaml = ".evn_test.yaml"
    with patch("sys.argv", ["py.test", "--db_drop", file_yaml]):
        transfer_vn.run()
    with patch("sys.argv", ["py.test", "--db_create", file_yaml]):
        transfer_vn.run()
    with patch("sys.argv", ["py.test", "--json_tables_create", file_yaml]):
        transfer_vn.run()
    with patch("sys.argv", ["py.test", "--col_tables_create", file_yaml]):
        transfer_vn.run()
def test_init():
    """Initialize test database"""
    with patch("sys.argv", ["py.test", "--db_drop", ".evn_test.yaml"]):
        transfer_vn.run()
    with patch("sys.argv", ["py.test", "--db_create", ".evn_test.yaml"]):
        transfer_vn.run()
    MANAGE_PG.create_json_tables()
    with patch("sys.argv",
               ["py.test", "--col_tables_create", ".evn_test.yaml"]):
        transfer_vn.run()
    # Instantiate stores.
    global STORE_PG, READ_PG, ENTITIES, FAMILIES, FIELDS, LOCAL_ADMIN_UNITS
    global OBSERVATIONS, OBSERVERS, PLACES, SPECIES, TAXO_GROUP, TERRITORIAL_UNIT, VALIDATIONS
    STORE_PG = StorePostgresql(CFG)
    READ_PG = ReadPostgresql(CFG)
    ENTITIES = Entities(CFG, STORE_PG)
    FAMILIES = Families(CFG, STORE_PG)
    FIELDS = Fields(CFG, STORE_PG)
    LOCAL_ADMIN_UNITS = LocalAdminUnits(CFG, STORE_PG)
    OBSERVATIONS = Observations(CFG, STORE_PG)
    OBSERVERS = Observers(CFG, STORE_PG)
    PLACES = Places(CFG, STORE_PG)
    SPECIES = Species(CFG, STORE_PG)
    TAXO_GROUP = TaxoGroup(CFG, STORE_PG)
    TERRITORIAL_UNIT = TerritorialUnits(CFG, STORE_PG)
    VALIDATIONS = Validations(CFG, STORE_PG)
Esempio n. 5
0
def test_status():
    """Check database counting."""
    file_yaml = ".evn_test.yaml"
    with patch("sys.argv", ["py.test", "--status", file_yaml]):
        transfer_vn.run()
Esempio n. 6
0
def test_full():
    """Check database full download."""
    file_yaml = ".evn_test.yaml"
    with patch("sys.argv", ["py.test", "--full", file_yaml]):
        transfer_vn.run()
Esempio n. 7
0
def test_version():
    """Check if version is defined."""
    with patch("sys.argv", ["py.test", "--version"]):
        with pytest.raises(SystemExit):
            transfer_vn.run()