Ejemplo n.º 1
0
def test_create_equivalence(potcar_family):
    """Create from file (during upload) and from contents and ensure equivalence."""
    potcar_file_cls = get_data_class('vasp.potcar_file')
    potcar_path = ['potcar', 'As', 'POTCAR']
    potcar_file, created = potcar_file_cls.get_or_create_from_contents(read_file(*potcar_path, mode='rb'))
    assert not created
    assert potcar_file.sha512 == potcar_file_cls.find_one(element='As').sha512
    assert potcar_file.uuid == potcar_file_cls.find_one(element='As').uuid

    potcar_cls = get_data_class('vasp.potcar')
    potcar, created = potcar_cls.get_or_create_from_contents(read_file(*potcar_path, mode='rb'))
    assert not created
    assert potcar.sha512 == potcar_cls.find_one(element='As').sha512
    assert potcar.uuid == potcar_cls.find_one(element='As').uuid
Ejemplo n.º 2
0
def test_write_incar(tmpdir, incar_dict):
    """Test writing and INCAR file from an IncarIo object."""

    incar_io = IncarIo(incar_dict=incar_dict)
    tempfile = str(tmpdir.join('INCAR'))
    incar_io.write(tempfile)
    assert read_file(path=tempfile) == str(incar_io)
Ejemplo n.º 3
0
def test_hashing(fresh_aiida_env):
    """Ensure the file and content sha512 hash equivalently for the same POTCAR."""
    potcar_file_cls = get_data_class('vasp.potcar_file')
    potcar_path = ['potcar', 'As', 'POTCAR']

    file_sha512 = potcar_file_cls.get_file_sha512(data_path(*potcar_path))
    content_sha512 = potcar_file_cls.get_contents_sha512(read_file(*potcar_path, mode='rb'))
    assert file_sha512 == content_sha512
Ejemplo n.º 4
0
def test_hashing(aiida_env):
    """Ensure the file and content md5 hash equivalently for the same POTCAR."""
    potcar_file_cls = get_data_class('vasp.potcar_file')
    potcar_path = ['potcar', 'As', 'POTCAR']

    file_md5 = potcar_file_cls.get_file_md5(data_path(*potcar_path))
    content_md5 = potcar_file_cls.get_contents_md5(read_file(*potcar_path))
    assert file_md5 == content_md5
Ejemplo n.º 5
0
def test_potcar_from_contents(potcar_family):
    """Create a PotcarIo from contents of a POTCAR file."""
    contents_as = read_file('potcar', 'As', 'POTCAR')
    from_ctor = PotcarIo(contents=contents_as)
    verify_potcario(from_ctor)
    assert from_ctor.node.uuid == get_data_class('vasp.potcar').find_one(element='As').uuid
    from_from = PotcarIo.from_(contents_as)
    assert from_ctor == from_from
Ejemplo n.º 6
0
def test_file_contents_equivalence(fresh_aiida_env):
    potcar_path_as = ['potcar', 'As', 'POTCAR']
    from_file = PotcarIo(path=data_path(*potcar_path_as))
    from_contents = PotcarIo(contents=read_file(
        *potcar_path_as).encode('utf-8'))
    assert from_file.sha512 == from_contents.sha512
Ejemplo n.º 7
0
def test_file_contents_equivalence(aiida_env):
    potcar_path_as = ['potcar', 'As', 'POTCAR']
    from_file = PotcarIo(path=data_path(*potcar_path_as))
    from_contents = PotcarIo(contents=read_file(*potcar_path_as))
    assert from_file.md5 == from_contents.md5