def test_add_subitem(self): """Test that subitem may be added to some item.""" TEST_TEXT = 'test3' TEST_TEXT_SUBITEM = 'test33' add(TEST_TEXT) items = load_items() parent_pk = items[0].pk add(TEST_TEXT_SUBITEM, parent_pk=parent_pk) subitem_pk = get_item(parent_pk).children[0] self.assertEqual(get_item(subitem_pk).title, TEST_TEXT_SUBITEM)
def test_add_subsubitem(self): """ Subitem to subitem can be added. """ TEST_TEXT_SUBITEM = 'sub test' TEST_TEXT_SUBSUBITEM = 'sub sub test' add(TEST_TEXT_SUBITEM) add('test2') items = load_items() parent_pk = items[1].pk add(TEST_TEXT_SUBITEM, parent_pk=parent_pk) parent = get_item(parent_pk) subitem = get_item(parent.children[0]) add(TEST_TEXT_SUBSUBITEM, parent_pk=subitem.pk) subitem = get_item(subitem.pk) subsubitem_pk = subitem.children[0] self.assertEqual(get_item(subsubitem_pk).title, TEST_TEXT_SUBSUBITEM)
def test_done(self): """Test adding one item""" add('step that will be done') items = load_items() pk = items[0].pk done(pk) i = get_item(pk) self.assertEqual(i.is_done, 'TRUE')
def test_active(self): """ Test activating one item. """ add('step that will be done and then activated again') items = load_items() pk = items[0].pk done(pk) active(pk) i = get_item(pk) self.assertEqual(i.is_done, 'FALSE')
def test_active_cli(self): """ Test command line version of active command. """ add('step that will be done and then activated again') items = load_items() pk = items[0].pk done(pk) output = subprocess.check_output( "../progressio/progressio.py active {}".format(pk), stderr=subprocess.STDOUT, shell=True) print output self.assertTrue("Item {} is marked as active".format(pk) in output) i = get_item(pk) self.assertEqual(i.is_done, 'FALSE')
def test_if_not_confirmed_not_deleted(self): """ If delete operation is not confirmed item is not deleted. """ # create progress.db p = subprocess.Popen('../progressio/progressio.py', stdin=subprocess.PIPE) p.communicate('y\n') # add item, it is added with pk=1 add('item to be deleted') p = subprocess.Popen( '../progressio/progressio.py delete 1', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) output = p.communicate('n\n')[0] self.assertFalse("Deleted item 1" in output) # item is in database self.assertFalse(get_item(1) is None)
def test_item_can_be_deleted(self): """ Item can be deleted and message is shown. """ # create progress.db p = subprocess.Popen('../progressio/progressio.py', stdin=subprocess.PIPE) p.communicate('y\n') # add item, it is added with pk=1 add('item to be deleted') p = subprocess.Popen( '../progressio/progressio.py delete 1', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) output = p.communicate('y\n')[0] self.assertTrue("Deleted item 1" in output) # item is not in database self.assertTrue(get_item(1) is None)
def test_get_non_existant_item(self): add('test') self.assertTrue(get_item(9999999) is None)