Commit 36b53a73 authored by Danielvdh03's avatar Danielvdh03
Browse files

Now CLI commits changes to database + added 4 more test cases

parent abeb0ab6
Description : This test is testing the functionality of finding user in a county
Pre-Requisites : None
Inputs
Select a Command : find_user
State : New York
County or All : Albany
Minimum Follower Count : 100
Maximum Follower Count :
All or Limit : All
Verification1 : Verify that all users via a manual SQL query that they are from the county of Albany
Verification2 : Verify that all returned users have more than 100 followers
Description : Verifying the ability to users only by state rather than by count
Pre-Requisites : None
Inputs
Command : find_user
State : Illinois
County or All : All
Minimum : 10000
Maximum : 100000
All or Limit Results : Limit
Maximum Results : 10
Verification1 : Verify by manual query that all returned users do in fact reside from Illinois
Verification2 : Verify that no more than 10 results were returned
Verification3 : Verify that all returned users are within the follower count range
Description : This test verifies that a user can successfully add a tweet
Pre-Requisites : None
Inputs:
Command : insert_tweet
Username of tweet : Bob
Contents of tweet : I love sleep
Number of likes : 450
Date tweet was created : 2020-09-23
Verification 1 : Make sure that Insert compiled without errors
Verification 2 : Query this manually on the Tweet table to make sure tweet got inserted into the Database
\ No newline at end of file
Description : Verifying that querying for poll results by county will yield accurate results
Pre-Requisites : None
Inputs:
command : county_results
Name of State : Georgia
Name of County : Fayette
Verification1 : Verify that there is a result returned
Verification2 : Verify that candidates are ordered from most votes to least amount of votes
Verification3 : Verify that same results can be replicated by manually querying for this data outside the CLI
......@@ -56,7 +56,7 @@ def generate_commands():
# Hardcoded list of available descriptions when running help command
def generate_descriptions():
descriptions = ("Enter in a state to view the total number of votes in the 2020 election. Option \"All\" to view votes in descneding order by state",
descriptions = ("Enter in a state to view the total number of votes in the 2020 election. Option \"All\" to view votes in descending order by state",
"Used to find users with high follower counts by county",
"Prints out the final voting standings by party in a specific county",
"Ranks counties in a given state or across the nation in a specific category (ex. Covid Cases, Income)",
......@@ -65,7 +65,7 @@ def generate_descriptions():
"Updates the final vote count for a party. Used to update vote counts for parties as votes are being processed",
"Updates the total number of votes by state. Used to update voting data as votes are being processed",
"Inserts new tweet to the database by a specific user",
"Prints out list of available commands and their optoins",
"Prints out list of available commands and their options",
"Closes the CLI"
)
......@@ -421,7 +421,7 @@ class Database:
query = "select count(tweet) from tweet inner join user on tweet.user_id=user.id where tweet > {0} and hashtag = \"{1}\"" \
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;" .format(likes, candidate_name, region, state )
" and county_id = (select id from county where name = \"{2}\" and state_id = (select id from state where name = \"{3}\")) ;".format(likes, candidate_name, region, state )
# print(query)
results = self.execute_query(query)
......@@ -488,13 +488,13 @@ class Database:
date = input("Enter the date that this tweet was created as YYYY-MM-DD : ")
date = date.strip()
user_id = self.get_user_id(username)
user_id = self.get_user_id(username) # need user_id use username to get it
tweet_id = 1 + self.get_tweet_id() #tweet id is number of tweets in table + 1
query = "insert into tweet (id, user_id, created_at, tweet, likes) \n"
query += "values({0}, {1}, \"{2}\", \"{3}\", {4});".format(tweet_id, user_id , date, tweet, likes)
print(query)
# print(query)
results = self.execute_query(query)
def get_user_id(self, user_name):
......@@ -540,10 +540,13 @@ if __name__ == "__main__":
client = Database()
while True:
db.commit()
command = input("Please select a command : ")
command = command.lower() # No longer case sensitive
command = command.strip()
if command == "quit": # Works
break
......@@ -568,11 +571,11 @@ if __name__ == "__main__":
client.group_county_by()
elif command == "get_tweet_candidate": # Untested
elif command == "get_tweet_candidate": # Untested - Should work
client.get_tweet_candidate()
elif command == "count_tweet_region": # Untested
elif command == "count_tweet_region": # Untested - Should work
client.count_tweet_region()
......@@ -584,7 +587,7 @@ if __name__ == "__main__":
client.update_state_count()
elif command == "insert_tweet": # Untested - Should work
elif command == "insert_tweet": # Works
client.insert_tweet()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment