Last active
August 29, 2015 14:05
-
-
Save SuperDoxin/495d320d86671e4941a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kassa | |
import inspect | |
import pytest | |
import random | |
def test_classes(): | |
assert inspect.isclass(kassa.Product) | |
def test_getprice(): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567017") | |
assert p.prijs==4.80 | |
def test_getname(): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567017") | |
assert p.name=="TestProduct" | |
def test_getname(): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567017") | |
assert p.barcode=="0001234567017" | |
def test_randattrs(): | |
name="TestProduct"+str(random.randint(0,100)) | |
price=random.uniform(1,10) | |
barcode="0001234567017" | |
p=kassa.Product(name=name,prijs=price,barcode=barcode) | |
assert p.name==name | |
assert p.prijs==price | |
assert p.barcode==barcode | |
def test_checkdigit(): | |
with pytest.raises(kassa.InvalidEANException): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567018") | |
with pytest.raises(kassa.InvalidEANException): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567025") | |
with pytest.raises(kassa.InvalidEANException): | |
p=kassa.Product(name="TestProduct",prijs=4.80,barcode="0001234567032") | |
def test_sum(): | |
p1=kassa.Product(name="TestProduct",prijs=random.uniform(1,10),barcode="0001234567017") | |
receipt=kassa.Receipt() | |
receipt.add(p1) | |
receipt.add(p1) | |
receipt.add(p1) | |
assert receipt.value==p1.prijs*3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment