示例#1
0
def test_change_item_name(happi_client: Client, item_info: Dict[str, Any]):
    item = happi_client.find_item(**item_info)
    assert item.name != 'new_name'
    item.name = 'new_name'
    item.save()
    # old entry should not exist anymore
    with pytest.raises(SearchError):
        happi_client.find_item(**item_info)
    # new entry with new name should be there
    new_item = happi_client.find_item(name=item.name)
    # prefix or other attributes should be the same
    assert new_item.prefix == item.prefix
    # we should only have one deivce now which is the new one
    assert happi_client.all_items == [new_item]
示例#2
0
def test_find_item(happi_client: Client, item_info: Dict[str, Any]):
    item = happi_client.find_item(**item_info)
    assert isinstance(item, OphydItem)
    assert item.prefix == item_info['prefix']
    assert item.name == item_info['name']
    # Test edit and save
    item.stand = 'DG3'
    item.save()
    loaded_item = happi_client.find_item(**item_info)
    assert loaded_item.prefix == item_info['prefix']
    assert loaded_item.name == item_info['name']
    # Bad load
    bad = {'a': 'b'}
    happi_client.backend.save('a', bad, insert=True)
    with pytest.raises(EntryError):
        happi_client.find_item(**bad)
示例#3
0
def test_add_and_find_item(happi_client: Client, valve: OphydItem,
                           valve_info: Dict[str, Any]):
    happi_client.add_item(valve)
    loaded_item = happi_client.find_item(**valve_info)
    assert loaded_item.prefix == valve.prefix
    assert loaded_item.name == valve.name