Beispiel #1
0
    def test_saving_and_retrieving_items(self):
        list_ = List()
        list_.save()

        first_item = ListItem()
        first_item.text = 'The first (ever) list item'
        first_item.list = list_
        first_item.save()

        second_item = ListItem()
        second_item.text = 'Item the second'
        second_item.list = list_
        second_item.save()

        saved_list = List.objects.first()
        self.assertEqual(saved_list, list_)

        saved_items = ListItem.objects.all()
        self.assertEqual(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]
        self.assertEqual(first_saved_item.text, 'The first (ever) list item')
        self.assertEqual(first_saved_item.list, list_)
        self.assertEqual(second_saved_item.text, 'Item the second')
        self.assertEqual(second_saved_item.list, list_)
 def create(self, validated_data):
     """
     instance create
     """
     newListItem = ListItem()
     newListItem.construct(**validated_data)
     newListItem.save()
     return newListItem
Beispiel #3
0
    def test_saving_and_retrieving_items( self):
        itemTexts = [ 'The first list item' ,'Item the second']

        for it in itemTexts:
            item = ListItem()
            item.text = it
            item.save()

        savedItems = ListItem.objects.all()
        self.assertEqual( savedItems.count() ,2)

        for count,it in enumerate(itemTexts):
            self.assertEqual( savedItems[count].text ,it)
Beispiel #4
0
2590726
2590723
2590727""".split("\n")

msgs = []
count = 0

for s in skus:
    count += 1
    try:
        src = SellerRateChart.objects.get(sku=s, seller__client=client_id)
    except Exception,e:
        msgs.append("ERROR @ row: %s for SKU: %s -- %s" % (count, s, repr(e)))

count = 0
if msgs:
    for msg in msgs:
        print msg
else:
    for s in skus:
        count += 1
        listitem = ListItem(list=list)
        src = SellerRateChart.objects.get(sku=s, seller__client=client_id)
        listitem.sku = src
        listitem.sequence = count
        listitem.status = 'active'
        listitem.save()
        msgs.append("SKU added: %s" % s)
    for msg in msgs:
        print msg