Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- Modify test to test more
- Fix table creation
- ViewTimeBot.__init__ calls Bot.__init__
  • Loading branch information
Martmists-GH committed Oct 20, 2016
1 parent 602d223 commit 003fa60
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ settings.ini
*.egg-info/
*.mp3
*.avi
.tox/
.tox/
*.db
*.db-journal
11 changes: 6 additions & 5 deletions asynctwitch/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ def _setup_points_db(file):
open(file,'a').close()
connection = sqlite3.connect(file)
cursor = connection.cursor()
cursor.execute("CREATE TABLE currency VALUES (username VARCHAR(30), balance INT)")
cursor.execute("CREATE TABLE currency (username VARCHAR(30), balance INT)")
connection.commit()
connection.close()

def _setup_ranks_db(file):
open(file,'a').close()
connection = sqlite3.connect(file)
cursor = connection.cursor()
cursor.execute("CREATE TABLE user_ranks VALUES (username VARCHAR(30), rankname TEXT)")
cursor.execute("CREATE TABLE currency_ranks VALUES (currency INT, rankname TEXT)")
cursor.execute("CREATE TABLE watched_ranks VALUES (time INT, rankname TEXT)")
cursor.execute("CREATE TABLE user_ranks (username VARCHAR(30), rankname TEXT)")
cursor.execute("CREATE TABLE currency_ranks (currency INT, rankname TEXT)")
cursor.execute("CREATE TABLE watched_ranks (time INT, rankname TEXT)")
connection.commit()
connection.close()

def _setup_time_db(file):
open(file,'a').close()
connection = sqlite3.connect(file)
cursor = connection.cursor()
cursor.execute("CREATE TABLE time_watched VALUES (username VARCHAR(30), time INT)")
cursor.execute("CREATE TABLE time_watched (username VARCHAR(30), time INT)")
connection.commit()
connection.close()

Expand Down Expand Up @@ -874,6 +874,7 @@ def undo_currency_database_changes(self):
class ViewTimeBot(Bot):
""" A Bot to track view time """
def __init__(self, *args, time_database='time.db', **kwargs):
super().__init__(*args, **kwargs)
if not aio_installed:
raise Exception("ViewTimeBot requires aiohttp to be installed!")
self.time_database_name = time_database
Expand Down
10 changes: 9 additions & 1 deletion run_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import asynctwitch as at

bot = at.Bot(
class Bot(at.CommandBot, at.RankedBot):
pass
bot = Bot(
user = 'justinfan100' # read-only client
)

@bot.command("test", desc="Some test command")
async def test(m, arg1:int):
pass

bot.add_rank("test rank", points=10)

@bot.override
async def raw_event(data):
print(data)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup(
name='asynctwitch',

version='4.0.1',
version='4.1.0',

description='Asynchonous wrapper for twitch IRC3',
long_description=long_description,
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
envlist = py35

[testenv]
deps=aiohttp
isodate
commands = python run_test.py

0 comments on commit 003fa60

Please sign in to comment.