class TestDataList(object): def setup(self): self.datalist = DataList() self.datalist.item_cls = Data def test_q_add(self): one = {'tag': "one"} two = {'tag': "two"} self.datalist.q_add([one, two]) assert len(self.datalist) == 2 assert self.datalist[0].tag == "one" assert self.datalist[1].tag == "two" def test_q_get(self): one = {'tag': "one"} two = {'tag': "two"} three = {'tag': "three"} self.datalist.q_add([one, two, three]) items = self.datalist.q_get([{'tag': "three"}]) assert len(items) == 1 item = items[0] assert item is self.datalist[2] assert item.tag == "three" def test_q_del(self): one = {'tag': "one"} two = {'tag': "two"} three = {'tag': "three"} self.datalist.q_add([one, two, three]) deleted = self.datalist.q_del([{'tag': "two"}]) assert len(deleted) == 1 assert deleted[0].tag == "two" assert len(self.datalist) == 2 assert self.datalist[0].tag == "one" assert self.datalist[1].tag == "three"
class TestDataList (object): def setup (self): self.datalist = DataList() self.datalist.item_cls = Data def test_q_add (self): one = {'tag':"one"} two = {'tag':"two"} self.datalist.q_add([one, two]) assert len(self.datalist) == 2 assert self.datalist[0].tag == "one" assert self.datalist[1].tag == "two" def test_q_get (self): one = {'tag':"one"} two = {'tag':"two"} three = {'tag':"three"} self.datalist.q_add([one, two, three]) items = self.datalist.q_get([{'tag':"three"}]) assert len(items) == 1 item = items[0] assert item is self.datalist[2] assert item.tag == "three" def test_q_del (self): one = {'tag':"one"} two = {'tag':"two"} three = {'tag':"three"} self.datalist.q_add([one, two, three]) deleted = self.datalist.q_del([{'tag':"two"}]) assert len(deleted) == 1 assert deleted[0].tag == "two" assert len(self.datalist) == 2 assert self.datalist[0].tag == "one" assert self.datalist[1].tag == "three"
def setup(self): self.datalist = DataList() self.datalist.item_cls = Data
def setup (self): self.datalist = DataList() self.datalist.item_cls = Data