Exemple #1
0
    def test_deleting_item(self):
        item = Item(id=0, content="hello world")
        item.save(self.cursor)

        item.delete(self.cursor)
        self.cursor.execute("SELECT * FROM items")
        raw_deleted = self.cursor.fetchone()
        self.assertIsNone(raw_deleted)
Exemple #2
0
    def test_saving_item_and_retrieving_it(self):
        item = Item(id=0, content="hello world")
        item.save(self.cursor)
        self.cursor.execute("SELECT * FROM items")
        # retrieve item back from database
        raw = self.cursor.fetchone()
        retrieved_item = Item.from_tuple(raw)

        # check that it is the one we saved
        self.assertEqual(retrieved_item.id, item.id)
        self.assertEqual(retrieved_item.content, item.content)
        self.assertEqual(retrieved_item.date_created, item.date_created)
Exemple #3
0
    def test_checking_item(self):
        item = Item(id=0, content="hello world")

        # ensure the item is unchecked
        item.checked = False

        item.save(self.cursor)
        self.cursor.execute("SELECT * FROM items")
        raw_unchecked = self.cursor.fetchone()
        # now check the item and retrieve it again
        item.check(self.cursor)
        self.cursor.execute("SELECT * FROM items")
        raw_checked = self.cursor.fetchone()

        item_unchecked = Item.from_tuple(raw_unchecked)
        item_checked = Item.from_tuple(raw_checked)

        self.assertFalse(item_unchecked.checked)
        self.assertTrue(item_checked.checked)
        self.assertNotEqual(item_unchecked.checked, item_checked.checked)
from mongoengine import connect
connect("comprank")
from app.topic import Topic
from app.comparison import Comparison
from app.item import Item
from app.category import Category

import csv

with open('data/tuxc.tsv') as names:
    reader = csv.DictReader(names, dialect='excel-tab')
    for row in reader:
        first = row['first']
        last = row['last']
        name = first + ' ' + last
        p = Item(name=name, description='XC Student Athlete', format='text')
        p.save()