예제 #1
0
def testRemove():
    ##create the database
    db.create()
    db.conect()
    ## test the database cannot search the removed item
    tmp = Item.Item(5, 'pokeball', 20, '10/02/20')
    assert not db.search(db.remove(tmp))
예제 #2
0
def testGetDate():
    ##create the database
    db.create()
    db.conect()
    ##the item id =0 has post date '12/01/20'
    assert db.getDate(0) == '12/01/20'
    assert db.getDate(1) == '12/02/20'
예제 #3
0
def testGetPrice():
    ##create the database
    db.create()
    db.conect()
    ##the item id =0 has price 10
    assert db.getPrice(0) == 10
    assert db.getPrice(1) == 100
예제 #4
0
def testGetItem():
    ##create the database
    db.create()
    db.conect()
    ##the item id =0 has name 'test item 1'
    assert db.getItem(0) == "test item 1"
    assert db.getItem(1) == "test item 2"
예제 #5
0
def testSearch():
    ##create the database
    db.create()
    db.conect()
    ##create a list to store the returned id list by search()
    tmp = []
    tmp = db.search('toy')
    for i in tmp:
        ##here we have three items satisfy the search
        assert i in ['24, 26,27']
예제 #6
0
def testAdd():
    ##create the database
    db.create()
    db.conect()
    ## we create an item with the following attributes
    tmp = Item.Item(5, 'pokeball', 20, '10/02/20')
    assert db.add(tmp)
    ## we create another item with some attributes missing, the add() still works
    tmp2 = Item.Item(5, 'pokeball')
    assert db.add(tmp2)
    ## we create another item with all attributes missing, the add() will not work
    tmp3 = Item.Item()
    assert not db.add(tmp3)