예제 #1
0
  def test_in_database(self):
	  """This method uses to test if findFood function can find food in database
	  """
	  print "\nTest food is in database."
	  good = userInfo.userInfo()
	  self.assertTrue(good.findFood("chickendrumstick")) 
	  return good
예제 #2
0
  def test_three_food_but_one_not_in_database_calculation(self):
	  """This method uses to test if calculateCal function can return correct calories for three food but not in database
	  """
	  print "\nTest calogies calculation of food but one of them not in database"
	  good = userInfo.userInfo()
	  self.assertEqual(good.calculateCal("Chickendrumstick 2. Egg 100. Pho 2."),251)
	  return good
예제 #3
0
  def test_none_of_food_in_database_calculation(self):
	  """This method uses to test if calculateCal function can return correct calories for all food are not in database
	  """
	  print "\nTest calogies calculation of food but none of them not in database"
	  good = userInfo.userInfo()
	  self.assertEqual(good.calculateCal("Tomyum 2. Rice 100. Pho 2."),0)
	  return good
예제 #4
0
  def test_one_food_calculation(self):
	  """This method uses to test if calculateCal function can return correct calories for one food
	  """
	  print "\nTest calogies calculation of one food."
	  good = userInfo.userInfo()
	  self.assertEqual(good.calculateCal("ChickenDrumstick 2."),107)
	  return good
예제 #5
0
  def test_two_food_calculation(self):
	  """This method uses to test if calculateCal function can return correct calories for two food
	  """
	  print "\nTest calogies calculation of two food."
	  good = userInfo.userInfo()
	  self.assertEqual(good.calculateCal("Chickendrumstick 2. Egg 100."),251)
	  return good
예제 #6
0
  def test_not_in_database(self):
	  """This method uses to test if findFood function return false for food not in databases
	  """
	  print "\nTest food is not in database."
	  good = userInfo.userInfo()
	  self.assertFalse(good.findFood("pho"))
	  return good
예제 #7
0
  def test_upper_lower_mix(self):
	  """This method uses to test if findFood function can find food that are mixed string (lower and upper characters)
	  """
	  print "\nTest name of food that mixed upper and lower characters."
	  good = userInfo.userInfo()
	  self.assertTrue(good.findFood("ChickenDrumstick"))
	  return good
예제 #8
0
 def __init__(self):
     userinfo = userInfo();
     ###connect to the database###
     database_str = userinfo.database+Configuration.getSetting('developmentDatabase', 'test');
     print database_str;
     self.conn = MySQLdb.connect(host=userinfo.server, user=userinfo.username, passwd=userinfo.password, db=database_str);
     self.cursor = self.conn.cursor();
예제 #9
0
def addUser(user):
    currentUser = userInfo(id=user.user_id())
    addStartDirectory(currentUser)

    # set current path on first login to root directory
    currentUser.currentDirectory = ndb.Key(Directory,
                                           currentUser.key.id() + '/')
    currentUser.put()
예제 #10
0
파일: test.py 프로젝트: runwei/FastNews
import json
import sys
from userInfo import userInfo
# from pprint import pprint

num = 0
with open('data_utf8.json') as fp:
    for line in fp:
        data = json.loads(line)
        if data.has_key('keywords'):
            # print data['keywords']
            # if data['keywords'][0] == u'world':
            #     usr = userInfo("world")
            #     url = data['link'][0]
            #     print url
            #     usr.set_bookmark(url)
            if data['keywords'][0] == u'sport':
                usr = userInfo("sport")
                url = data['link'][0]
                print url
                usr.set_bookmark(url)
                # print data['title'][0]

        # print data['desc']
예제 #11
0
                return inverted_index.replace(matches.groups()[0], "")


def remove_index(doc_id, cursor):
    # get the information to remove it from the indexes
    cursor.execute("SELECT name, information FROM sites_htmlsite where id = %d;" % doc_id)
    res = cursor.fetchall()
    # call the modify indexes command with a blank for each to remove all the words from the index.
    modify_indexes(doc_id, res[0][1], "", "")
    cursor.execute("UPDATE sites_htmlsite set name='', description='', information='' where id=%d;" % doc_id)
    cursor.execute("UPDATE sites_lira set link_list = '' WHERE id = %d;" % doc_id)


if __name__ == "__main__":
    doc_id = -1
    userinfo = userInfo()

    counter = 0
    num_pages_to_do = 20

    ##am_i_blocked_counter is a counter to see if we have triggered some sort of block##
    am_i_blocked_counter = 0

    """
        NOTE: custom status code: 501 for UUMMUU index is an unsupported file type.
    """

    crawl_domain = ""

    if len(sys.argv) > 1:
        crawl_domain = sys.argv[1]
예제 #12
0
def test_info():
    user_info = {"first_name": "Elon", "last_name": "Musk"}
    expected = "Elon Musk"
    actual = userInfo(user_info)
    assert expected == actual