Пример #1
0
def test_super_toaster_toast_when_flying():
    flying_toaster = SuperToaster(2, 'Captain Toaster')

    flying_toaster.add_toasts(2, 'Corned Beef')
    flying_toaster.set_timer(3)

    flying_toaster.fly()
    
    with pytest.raises(Exception) as exception:
        flying_toaster.toast()
Пример #2
0
def test_super_boost_toast_when_flying():
    flying_toaster = SuperToaster(2, 'DareToaster', 'red')
    
    flying_toaster.add_toasts(2, 'Bread?')
    flying_toaster.set_timer(3)

    flying_toaster.fly()
    
    with pytest.raises(Exception) as exception:
        flying_toaster.super_boost_toast()
Пример #3
0
def test_remove_toasts_when_flying():
    flying_toaster = SuperToaster(2, 'Moon Toaster')
    flying_toaster.add_toasts(2, 'Moonbread')

    flying_toaster.fly()

    with pytest.raises(Exception) as exception:
        flying_toaster.remove_toasts()
Пример #4
0
def get_toaster(toaster_type):
    try:
        slots = input('\nHow many slots?: ')
        colour = input('\nWhich colour?: ')

        toaster = None

        if toaster_type == str(1):
            toaster = Toaster(int(slots), colour)

        elif toaster_type == str(2):
            alias = input('\nWhat is the alias of your toaster?: ')

            toaster = SuperToaster(int(slots), alias, colour)

        print('\nHere is your wonderful toaster!\n')
        print_toaster(toaster)

        toasts = input('\nHow many toasts would you like?: ')
        bread = input('\nWhich bread?: ')
        toaster.add_toasts(int(toasts), bread)

        time = input('\nHow many seconds?: ')
        toaster.set_timer(int(time))

        toaster.toast()

    except:
        exit(1)
Пример #5
0
def test_create_super_toaster_wo_colour():
    slots = 4
    alias = 'Black Toaster'

    super_toaster = SuperToaster(slots, alias)

    assert super_toaster is not None
    assert isinstance(super_toaster, SuperToaster)
    assert len(super_toaster.slots) == slots
    assert super_toaster.alias == alias
    assert super_toaster.colour == 'gold'
Пример #6
0
def test_set_timer_when_flying():
    flying_toaster = SuperToaster(2, 'Agent Toaster')

    flying_toaster.fly()

    with pytest.raises(Exception) as exception:
        flying_toaster.set_timer(30)
Пример #7
0
def test_add_toasts_when_flying():
    flying_toaster = SuperToaster(2, 'Spider-Toaster')

    flying_toaster.fly()

    with pytest.raises(Exception) as exception:
        flying_toaster.add_toasts(2, 'Bread')
Пример #8
0
import os
import sys
import pytest

syspath = sys.path.insert(
    0,
    os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from flying_toaster.super_toaster import SuperToaster

test_toaster = SuperToaster(2, 'Super-Toaster')

def test_create_super_toaster():
    slots = 4
    alias = 'Black Toaster'
    colour = 'black'

    super_toaster = SuperToaster(slots, alias, colour)

    assert super_toaster is not None
    assert isinstance(super_toaster, SuperToaster)
    assert len(super_toaster.slots) == slots
    assert super_toaster.alias == alias
    assert super_toaster.colour == colour

def test_create_super_toaster_wo_colour():
    slots = 4
    alias = 'Black Toaster'

    super_toaster = SuperToaster(slots, alias)