Esempio n. 1
0
    def test_show_available_products(self):
        """ test show_available_products function """
        result = db.show_available_products()
        self.assertEqual(
            result, {
                'prd001': {
                    'description': '60-inch TV stand',
                    'product_type': 'livingroom',
                    'quantity_available': '3'
                },
                'prd002': {
                    'description': 'L-shaped sofa',
                    'product_type': 'livingroom',
                    'quantity_available': '1'
                },
                'prd005': {
                    'description': 'Nightstand',
                    'product_type': 'bedroom',
                    'quantity_available': '20'
                }
            })

        with patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            db.drop_database(DATABASE)
            result = db.show_available_products()
            self.assertEqual(result, {})
            self.assertEqual(fake_stdout.getvalue().strip(),
                             f'Database {DATABASE} not found.')
Esempio n. 2
0
    def test_show_rentals(self):
        """ test show_rentals function """
        result = db.show_rentals("prd002")
        self.assertEqual(
            result, {
                'user001': {
                    'name': 'Albert Einstein',
                    'address': '7 Vine Drive, Cleveland, TN 37312',
                    'phone_number': '559-555-0107',
                    'email': '*****@*****.**'
                },
                'user004': {
                    'name': 'Enrico Fermi',
                    'address': '468 Wilson St., Solon, OH 44139',
                    'phone_number': '567-555-0199',
                    'email': '*****@*****.**'
                },
                'user005': {
                    'name': 'Jane Goodall',
                    'address': '52 S. Summer St., Littleton, CO 80123',
                    'phone_number': '970-555-0171',
                    'email': '*****@*****.**'
                }
            })

        with patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            db.drop_database(DATABASE)
            result = db.show_rentals("prd002")
            self.assertEqual(result, {})
            self.assertEqual(fake_stdout.getvalue().strip(),
                             f'Database {DATABASE} not found.')
Esempio n. 3
0
 def go_to_MainPanel(self):
     with open("resources/first.txt", "r") as file:
         content = file.read()
         print(content)
         if content == "True":
             database.drop_database()
             database.start_database()
             with open("resources/first.txt", "w") as file:
                 file.write("False")
         else:
             pass
     sm.add_widget(MainPanel(name="MainPanel"))
     sm.transition = SlideTransition(direction = "left")
     sm.current = "MainPanel"
Esempio n. 4
0
 def tearDown(self):
     """ empty database after each test """
     db.drop_database(DATABASE)
Esempio n. 5
0
            'wget',
            corpus_location,
            '-P',
            corpus_path,
        ])
    else:
        print "Corpus already downloaded, skipping."

    print "Unzipping songs..."
    if len(os.listdir(corpus_path)) > 1:
        print "Songs already unzipped, skipping."
    else:
        subprocess.check_call([
            'tar',
            '-xzf',
            './corpus/music_repo.tar',
            '-C',
            corpus_path,
        ])
        print "Successfully unzipped songs."

if __name__ == '__main__':
    if os.path.exists(db['path']):
        print "Dropping existing database..."
        drop_database()
    print "Setting up the database..."
    setup_database()
    print "Finished database setup.\n"
    download_corpus()
    csv_import()
Esempio n. 6
0
            corpus_location,
            '-P',
            corpus_path,
        ])
    else:
        print "Corpus already downloaded, skipping."

    print "Unzipping songs..."
    if len(os.listdir(corpus_path)) > 1:
        print "Songs already unzipped, skipping."
    else:
        subprocess.check_call([
            'tar',
            '-xzf',
            './corpus/music_repo.tar',
            '-C',
            corpus_path,
        ])
        print "Successfully unzipped songs."


if __name__ == '__main__':
    if os.path.exists(db['path']):
        print "Dropping existing database..."
        drop_database()
    print "Setting up the database..."
    setup_database()
    print "Finished database setup.\n"
    download_corpus()
    csv_import()
Esempio n. 7
0
    usernames = []
    for i in range(0, batch_count):
        start_ix = i * batch_size
        end_ix = start_ix + batch_size
        batch = array[start_ix:end_ix]
        print(len(batch))
        if len(batch) > 0:
            usernames.extend(get_author_from_tweet_id(batch))
    usernames = list(dict.fromkeys(usernames))
    return usernames


if __name__ == "__main__":

    database.drop_database()
    database.initialise()

    users = fetch_usernames(tweet_ids)

    all_tweets = pd.DataFrame([])

    for user in users:
        user_details = get_user_details(user)
        followers = user_details.followers_count
        friends = user_details.friends_count
        favourites = user_details.favourites_count
        account_created = user_details.created_at
        verified = user_details.verified

        tweets = get_tweets_for_user(user)