Ejemplo n.º 1
0
def _computer_peri(place_thing, thing):
    from cc import peripheral

    side = 'left'

    step(
        f'Place {place_thing} on {side} side of computer\n'
        "Don't turn it on!",
    )

    c = peripheral.wrap(side)
    assert c is not None

    from computercraft.subapis.peripheral import ComputerMixin
    tbl = get_object_table(f'peripheral.wrap("{side}")')
    assert get_class_table(ComputerMixin) == tbl

    assert c.isOn() is False
    assert isinstance(c.getID(), int)
    assert c.getLabel() is None
    assert c.turnOn() is None

    step(f'{thing.capitalize()} must be turned on now')

    assert c.shutdown() is None

    step(f'{thing.capitalize()} must shutdown')

    step(f'Now turn on {thing} manually and enter some commands')

    assert c.reboot() is None

    step(f'{thing.capitalize()} must reboot')

    print('Test finished successfully')
Ejemplo n.º 2
0
import random

from computercraft.subapis.peripheral import CCSpeaker
from cc import import_file, os, peripheral

_lib = import_file('_lib.py', __file__)

side = 'left'

_lib.step(f'Attach speaker at {side} side of computer')

m = peripheral.wrap(side)

tbl = _lib.get_object_table(f'peripheral.wrap("{side}")')
assert _lib.get_class_table(CCSpeaker) == tbl

for _ in range(48):
    assert m.playNote(
        random.choice([
            'bass',
            'basedrum',
            'bell',
            'chime',
            'flute',
            'guitar',
            'hat',
            'snare',
            'xylophone',
            'iron_xylophone',
            'pling',
            'banjo',
Ejemplo n.º 3
0
def craft2():
    c = peripheral.wrap('right')
    return c.craft()
# TODO: support these methods
del tbl['function']['getName']
del tbl['function']['find']

tbl['function']['get_term_target'] = True

assert _lib.get_class_table(peripheral) == tbl

_lib.step('Remove all peripherals')

side = 'top'

assert peripheral.getNames() == []
assert peripheral.getType(side) is None
assert peripheral.isPresent(side) is False
assert peripheral.wrap(side) is None

_lib.step(f'Put disk drive on {side} side of computer')

assert peripheral.getNames() == [side]
assert peripheral.getType(side) == 'drive'
assert peripheral.isPresent(side) is True
d = peripheral.wrap(side)
assert d is not None
assert d.isDiskPresent() is False

print('Remove disk drive')

print('Test finished successfully')