def test_erase(self):
     words = ["a", "b", "c", "d"]
     for i in words:
         WordFrequency(word=i).put()
     self.assertEqual(WordFrequency.query().count(), 4)
     request = make_request(r'/admin/frequency_dictionary/delete', "POST", True)
     response = request.get_response(main.app)
     self.assertEqual(response.status_int, 200)
     task_response = self.run_tasks(1)[0]
     self.assertEqual(task_response.status_int, 200)
     self.assertEqual(WordFrequency.query().count(), 0)
 def test_erase(self):
     words = ["a", "b", "c", "d"]
     for i in words:
         WordFrequency(word=i).put()
     self.assertEqual(WordFrequency.query().count(), 4)
     request = make_request(r'/admin/frequency_dictionary/delete', "POST",
                            True)
     response = request.get_response(main.app)
     self.assertEqual(response.status_int, 200)
     task_response = self.run_tasks(1)[0]
     self.assertEqual(task_response.status_int, 200)
     self.assertEqual(WordFrequency.query().count(), 0)
 def test_no_admin(self):
     for words, count in [([{
             "w": "a",
             "d": "1"
     }, {
             "w": "b",
             "d": "2"
     }, {
             "w": "c",
             "d": "3"
     }], 0),
                          ([{
                              "w": "t",
                              "d": "1"
                          }, {
                              "w": "y",
                              "d": "2"
                          }, {
                              "w": "c",
                              "d": "3"
                          }], 0)]:
         request = make_request(r'/admin/frequency_dictionary/add', "POST",
                                False, "json={0}".format(json.dumps(words)))
         response = request.get_response(main.app)
         self.assertEqual(response.status_int, 302)
         self.assertEqual(WordFrequency.query().count(), 0)
 def test_add(self):
     for words, count in [([{
             "w": "a",
             "d": "1"
     }, {
             "w": "b",
             "d": "2"
     }, {
             "w": "c",
             "d": "3"
     }], 3),
                          ([{
                              "w": "t",
                              "d": "1"
                          }, {
                              "w": "y",
                              "d": "2"
                          }, {
                              "w": "c",
                              "d": "3"
                          }], 5)]:
         request = make_request(r'/admin/frequency_dictionary/add', "POST",
                                True, "json={0}".format(json.dumps(words)))
         response = request.get_response(main.app)
         self.assertEqual(response.status_int, 200)
         task_response = self.run_tasks(1)[0]
         self.assertEqual(task_response.status_int, 200)
         self.assertEqual(WordFrequency.query().count(), count)
 def test_no_admin(self):
     for words, count in [([{"w": "a", "d": "1"}, {"w": "b", "d": "2"}, {"w": "c", "d": "3"}], 0),
                          ([{"w": "t", "d": "1"}, {"w": "y", "d": "2"}, {"w": "c", "d": "3"}], 0)]:
         request = make_request(r'/admin/frequency_dictionary/add', "POST", False,
                                "json={0}".format(json.dumps(words)))
         response = request.get_response(main.app)
         self.assertEqual(response.status_int, 302)
         self.assertEqual(WordFrequency.query().count(), 0)
 def test_add(self):
     for words, count in [([{"w": "a", "d": "1"}, {"w": "b", "d": "2"}, {"w": "c", "d": "3"}], 3),
                          ([{"w": "t", "d": "1"}, {"w": "y", "d": "2"}, {"w": "c", "d": "3"}], 5)]:
         request = make_request(r'/admin/frequency_dictionary/add', "POST", True,
                                "json={0}".format(json.dumps(words)))
         response = request.get_response(main.app)
         self.assertEqual(response.status_int, 200)
         task_response = self.run_tasks(1)[0]
         self.assertEqual(task_response.status_int, 200)
         self.assertEqual(WordFrequency.query().count(), count)