Esempio n. 1
0
    def setUpClass(self):
        """
        Set up the unit test.
        """
        self.db = DB()

        self.email = '*****@*****.**'
        self.password = '******'
        self.fullname = 'ABC'

        self.user = User(self.db)
        self.user.create_new_user(self.email, self.password, self.fullname)
        self.user_id = self.user.check_email_match(self.email)

        self.email_1 = '*****@*****.**'
        self.password_1 = 'klmno'
        self.fullname_1 = 'XYZ'

        self.user_1 = User(self.db)
        self.user_1.create_new_user(self.email_1, self.password_1,
                                    self.fullname_1)
        self.user_id_1 = self.user_1.check_email_match(self.email_1)

        self.fitness = Fitness(self.db, self.user_id)
        self.fitness_dict = {'WorkoutType': 'Running',\
                             'Minutes': 10.0,\
                             'CaloriesBurned': 100.9}
        self.fitness_1 = Fitness(self.db, self.user_id_1)
        self.fitness_dict_1 = {'WorkoutType': 'Sleeping',\
                             'Minutes': 100.0,\
                             'CaloriesBurned': 10.9}

        self.dt1 = datetime.utcnow()
        self.unix_time = round(time.time())
Esempio n. 2
0
 def setUpClass(self):
     """
     Set up the unit test.
     """
     self.db = DB()
     self.table = "TestingTable"
     cmd = (
         "CREATE TABLE TestingTable (id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, "
         "name varchar(30), age INT(3));")
     self.db.insert_data(cmd)
Esempio n. 3
0
 def setUpClass(self):
     """
     Set up the unit test.
     """
     self.db = DB()
     self.email = '*****@*****.**'
     self.password = '******'
     self.fullname = 'ABC'
     
     self.user = User(self.db)
     self.user.create_new_user(self.email, self.password, self.fullname)
     self.user_id = self.user.check_email_match(self.email)
Esempio n. 4
0
    def setUpClass(self):
        """
        Set up the unit test.
        """
        self.db = DB()

        self.email = '*****@*****.**'
        self.password = '******'
        self.fullname = 'ABC'

        self.user = User(self.db)
        self.user.create_new_user(self.email, self.password, self.fullname)
        self.user_id = self.user.check_email_match(self.email)

        self.email_1 = '*****@*****.**'
        self.password_1 = 'klmno'
        self.fullname_1 = 'XYZ'

        self.user_1 = User(self.db)
        self.user_1.create_new_user(self.email_1, self.password_1,
                                    self.fullname_1)
        self.user_id_1 = self.user_1.check_email_match(self.email_1)

        self.email_2 = '*****@*****.**'
        self.password_2 = 'qqq'
        self.fullname_2 = 'ASD'

        self.user_2 = User(self.db)
        self.user_2.create_new_user(self.email_2, self.password_2,
                                    self.fullname_2)
        self.user_id_2 = self.user_2.check_email_match(self.email_2)

        self.diet = Diet(self.db, self.user_id)
        self.diet_1 = Diet(self.db, self.user_id_1)
        self.diet_2 = Diet(self.db, self.user_id_2)


        self.diet_dict = {'Item': 'Apple',\
                         'ServingSize': 1.0,\
                         'Barcode': False,\
                         'nutri_dict': {'Cals': 100.0,'Protein': 100.0, 'Carbs': 100.0, 'Fat': 100.0, 'Fiber': 100.0}}
        self.diet_dict_1 = {'Item': 'Orange',\
                         'ServingSize': 2.0,\
                         'Barcode': False,\
                         'nutri_dict': {'Cals': 105.0,'Protein': 105.0, 'Carbs': 105.0, 'Fat': 105.0, 'Fiber': 105.0}}
        self.diet_dict_2 = {'Item': 'banana',\
                         'ServingSize': 2.0,\
                         'Barcode': False,\
                         'nutri_dict': {'Cals': 101.0,'Protein': 101.0, 'Carbs': 101.0, 'Fat': 101.0, 'Fiber': 101.0}}

        self.dt1 = datetime.utcnow()
        self.unix_time = round(time.time())
Esempio n. 5
0
 def initialize_components(self):
     self.__dbinstance = DB()
     self.__dbinstance.create()
     songpaths = self.__dbinstance.executeSelect('SELECT * FROM song')
     # Iniatializes Tk() for importing purposes
     self.__root = Tk()
     self.__root.withdraw()
     # adding songs from hard drive to objects
     for song in songpaths:
         self.__addSongToEnvironment(song)
     strError = 'The following files coudn\'t be found and therefore were excluded from your library: '
     if len(self.songsMissing) != 0:
         for path in self.songsMissing:
             strError += '\n' + path + '\n'
         tkinter.messagebox.showinfo(title="Warning!", message=strError)
Esempio n. 6
0
    def setUpClass(self):
        """
        Set up the unittest.
        """
        self.db = DB()

        self.email = '*****@*****.**'
        self.password = '******'
        self.fullname = 'ABC'

        self.user = User(self.db)
        self.user.create_new_user(self.email, self.password, self.fullname)
        self.user_id = self.user.check_email_match(self.email)

        self.email_1 = '*****@*****.**'
        self.password_1 = 'klmno'
        self.fullname_1 = 'XYZ'

        self.user_1 = User(self.db)
        self.user_1.create_new_user(self.email_1, self.password_1,
                                    self.fullname_1)
        self.user_id_1 = self.user_1.check_email_match(self.email_1)

        self.sleep = Sleep(self.db, self.user_id)
        self.sleep_1 = Sleep(self.db, self.user_id_1)

        self.sleep_time = datetime.utcnow()
        self.wakeup_time = datetime.utcnow() + timedelta(minutes=1)
        self.sleep_dict = {'Nap': False,\
                           'SleepTime': self.sleep_time,\
                           'WakeupTime': self.wakeup_time}

        self.sleep_time_1 = datetime.utcnow()
        self.wakeup_time_1 = datetime.utcnow() + timedelta(minutes=2)
        self.sleep_dict_1 = {'Nap': False,\
                           'SleepTime': self.sleep_time_1,\
                           'WakeupTime': self.wakeup_time_1}

        self.dt1 = datetime.utcnow()
        self.unix_time = round(time.time())
Esempio n. 7
0
    def setUpClass(self):
        """
        Set up the unit test.
        """
        self.db = DB()

        self.email = '*****@*****.**'
        self.password = '******'
        self.fullname = 'ABCD'

        self.user = User(self.db)
        self.user.create_new_user(self.email, self.password, self.fullname)
        self.user_id = self.user.check_email_match(self.email)

        self.goals = Goals(self.db, self.user_id)
        self.diet_goal_dict = {'Type': 'Calories', 'Value': 1000.0}
        self.fitness_goal_dict = {'Type': 'FitnessMinutes', 'Value': 100.0}
        self.sleep_goal_dict = {'Type': 'SleepHours', 'Value': 10.0}

        self.goals.set_goal(self.diet_goal_dict)
        self.goals.set_goal(self.fitness_goal_dict)
        self.goals.set_goal(self.sleep_goal_dict)
Esempio n. 8
0
           "(WorkoutType varchar(256), Minutes DOUBLE NOT NULL, CaloriesBurned DOUBLE NOT NULL, "
           "Datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UserID INT(11) UNSIGNED, FOREIGN KEY (UserID) "
           "REFERENCES Users(id));")

goals = ("CREATE TABLE Goals "
         "(Type varchar(50), Value DOUBLE, "
         "Datetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UserID INT(11) UNSIGNED, FOREIGN KEY (UserID) "
         "REFERENCES Users(id));")

def set_up_db(db: DB) -> None:
    db.insert_data(users)
    db.insert_data(sleep)
    db.insert_data(diet)
    db.insert_data(fitness)
    db.insert_data(goals)

def drop_all_tables(db: DB) -> None:
    db.insert_data('drop table Sleep')
    db.insert_data('drop table Diet')
    db.insert_data('drop table Fitness')
    db.insert_data('drop table Goals')
    db.insert_data('drop table Users')


db = DB(False)
try:
    set_up_db(db)
    print("Production DB is set up.")
except:
    pass
Esempio n. 9
0
    Parameters
    ----------
    token : str
        Unique user token.

    Returns
    -------
    result : int
        If successful, returns user ID. Otherwise, returns -1.
    """
    msg, code = USER.decode_token(token)
    if code != 200:
        return -1
    return int(msg)


if __name__ == '__main__':
    test = False
    try:
        test = sys.argv[1]
        test = bool(test)
    except:
        test = False

    print(test)
    DB_OBJECT = DB(test)
    USER = User(DB_OBJECT)

    app.run(host="0.0.0.0", port=5000, debug=False)
Esempio n. 10
0
from backend.db import DB

db = DB()
print(db.get_station_types())

db.create_event(1,1,123123,12.1231232,324.2323123,1234.213124,2424.54545)