Skip to content

Commit

Permalink
added delete global dictionary test, fixed bug with it.
Browse files Browse the repository at this point in the history
issue #6
  • Loading branch information
i-pavlov committed Apr 5, 2014
1 parent db642f3 commit e2337ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions handlers/global_dictionary_word_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def __init__(self, *args, **kwargs):
def post(self, *args, **kwargs):
for word in ndb.gql("SELECT word FROM GlobalDictionaryWord").fetch():
word.key.delete()
for json in ndb.gql("SELECT timestamp FROM GlobalDictionaryJson").fetch():
json.key.delete()


class GlobalDictionaryGetWordsHandler(APIRequestHandler):
Expand Down
10 changes: 9 additions & 1 deletion tests/global_dictionary_word_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_add(self):
response = request.get_response(main.app)
self.assertEqual(json.loads(response.body)["words"], [])
self.assertEqual(json.loads(response.body)["timestamp"], timestamp)
time.sleep(0.01)
time.sleep(1)
request = make_request("/admin/global_dictionary/add_words", "POST", True, 'json=["f", "g", "h"]')
request.get_response(main.app)
task_response = self.run_tasks(1)
Expand Down Expand Up @@ -153,6 +153,14 @@ def test_get_page(self):
response = request.get_response(main.app)
self.assertEqual(response.status_int, 200)

def test_delete(self):
url = "/admin/global_dictionary/delete"
request = make_request(url, "POST", True, '0')
response = request.get_response(main.app)
task_response = self.run_tasks(1)
self.assertEqual(GlobalDictionaryWord.query().count(), 0)
self.assertEqual(GlobalDictionaryJson.query().count(), 0)


def tearDown(self):
self.testbed.deactivate()
Expand Down

0 comments on commit e2337ba

Please sign in to comment.