Esempio n. 1
0
def test_add_item():
    tarallo_session = Tarallo(t_url, t_token)
    ram = Item()
    ram.code = "!N\\/@L!D"
    ram.features["type"] = "ram"
    ram.location = "Table"

    tarallo_session.add_item(ram)
Esempio n. 2
0
def test_add_item():
    tarallo_session = Tarallo(t_url, t_token)

    ram = ItemToUpload()
    ram.set_code("!N\\/@L!D")
    ram.set_parent("Table")
    ram.features = {'type': 'ram'}
    tarallo_session.add_item(ram)
Esempio n. 3
0
def test_add_item():
    tarallo_session = Tarallo(t_url, t_token)
    data = {
        'code': "!N\\/@L!D",
        'features': {
            'type': 'ram'
        },
        'parent': 'Table'
    }
    ram = ItemToUpload(data)
    tarallo_session.add_item(ram)
Esempio n. 4
0
def test_add_item_cloned():
    tarallo_session = Tarallo(t_url, t_token)
    cpu = tarallo_session.get_item("C1")
    assert cpu is not None
    # it comes from a computer, path will still contain that, I don't care: I want it on the Table.
    # Send this location to the server, not the path.
    cpu.parent = "Table"
    # Let the server generate another code (since there's no way to delete items permanently we
    # can't test manually assigned codes... or rather we can, but just once)
    cpu.code = None
    # Add it: should succeed
    assert tarallo_session.add_item(cpu)

    # This stuff should be updated
    assert cpu.code is not None
    assert not cpu.code == "C1"
    # Just set path to none after inserting an item. The server doesn't return the full path so you have no way to
    # assign the correct value to this variable.
    # This assert checks just that:
    assert cpu.path is None

    # Let's get the entire item again and check...
    cpu = tarallo_session.get_item(cpu.code)
    assert cpu.path[-1:] == ['Table']
    assert cpu.location == 'Table'

    # This may seem redundant, but these are different feature types...
    assert cpu.features["brand"] == "AMD"
    assert cpu.features["type"] == "cpu"
    assert cpu.features["cpu-socket"] == "am3"
    assert cpu.features["frequency-hertz"] == 3000000000
Esempio n. 5
0
def test_add_item_cloned():
    tarallo_session = Tarallo(t_url, t_token)
    cpu = tarallo_session.get_item("C100TEST")
    assert cpu is not None

    cpu_to_upload = ItemToUpload(cpu)
    assert cpu.code == cpu_to_upload.code
    assert cpu.location[-1] == cpu_to_upload.parent
    assert len(cpu.features) == len(cpu_to_upload.features)

    # It comes from a computer, path will still contain that, I don't care: I want it on the Table.
    # Send this location to the server, not the path.
    cpu_to_upload.set_parent("Table")
    assert cpu.location[-1] != cpu_to_upload.parent

    # Let the server generate another code (since there's no way to delete items permanently we
    # can't test manually assigned codes... or rather we can, but just once)
    cpu_to_upload.set_code(None)
    assert cpu.code != cpu_to_upload.code

    # Add it: should succeed
    assert tarallo_session.add_item(cpu_to_upload)

    # Let's get the entire item again and check...
    # The generated code was added to the original dict
    cpu_cloned = tarallo_session.get_item(cpu_to_upload.code)

    assert cpu_cloned.code != cpu.code
    assert cpu_cloned.location[-1] == cpu_to_upload.parent
    assert len(cpu_cloned.features) == len(cpu_to_upload.features)
Esempio n. 6
0
def test_add_item():
    tarallo_session = Tarallo(t_url, t_token)
    ram = ItemToUpload()
    ram.features["type"] = "ram"
    ram.features["color"] = "red"
    ram.features["capacity-byte"] = 1024 * 1024 * 512  # 512 MiB
    ram.parent = "Table"

    assert tarallo_session.add_item(ram)

    # set the code to the one received from the server
    assert ram.code is not None
    assert isinstance(ram.code, str)

    # Let's get it again and check...
    ram = tarallo_session.get_item(ram.code)
    assert ram.location == 'Table'
    assert ram.features["type"] == "ram"
    assert ram.features["color"] == "red"
    assert ram.features["capacity-byte"] == 1024 * 1024 * 512
Esempio n. 7
0
def test_add_item():
    tarallo_session = Tarallo(t_url, t_token)
    ram = Item()
    ram.features["type"] = "ram"
    ram.features["color"] = "red"
    ram.features["capacity-byte"] = 1024 * 1024 * 512  # 512 MiB
    ram.location = "LabFis4"

    assert tarallo_session.add_item(ram) is True

    # set the code to the one received from the server
    assert ram.code is not None
    assert isinstance(ram.code, str)

    # Let's get it again and check...
    ram = tarallo_session.get_item(ram.code)
    assert ram.path[-1:] == ['LabFis4']
    assert ram.location == 'LabFis4'
    assert ram.features["type"] == "ram"
    assert ram.features["color"] == "red"
    assert ram.features["capacity-byte"] == 1024 * 1024 * 512
Esempio n. 8
0
def test_add_item_cloned():
    tarallo_session = Tarallo(t_url, t_token)
    cpu = tarallo_session.get_item("C1")
    assert cpu is not None
    # it comes from a computer, path will still contain that, I don't care: I want it on the Table.
    # Send this location to the server, not the path.
    # Let the server generate another code (since there's no way to delete items permanently we
    # can't test manually assigned codes... or rather we can, but just once)
    # Add it: should succeed

    # the following lines convert a Item -> ItemToUpload
    # and test some basic stuff
    data = cpu.serializable()
    del data["code"]
    data["parent"] = data.get("location")[-1]
    del data["location"]
    assert data["parent"] == 'Table'
    cpu_toUpload = ItemToUpload(data)
    assert tarallo_session.add_item(cpu_toUpload)

    # Let's get the entire item again and check...
    cpu = tarallo_session.get_item(cpu.code)