Beispiel #1
0
 def get_slack_id(self, real_name):
     query = "SELECT slack_id FROM members WHERE real_name = (%s)"
     result = dbutils.execute_fetchone(self.db, query, (real_name, ))
     if result is None:
         self.update_members()
         result = dbutils.execute_fetchone(self.db, query, (real_name, ))
         if result is None:
             return result
     return result[0]
    def test_record_absence(self):
        expected_value = False
        self.bot.record_absence("12345", "1477908000")
        query = "select Present from Attendance where slack_id='12345' and post_timestamp = '1477908000'"
        result = dbutils.execute_fetchone(self.test_db, query)[0]

        self.assertEqual(result, expected_value)
Beispiel #3
0
 def get_latest_post_data(self):
     query = "SELECT post_timestamp, channel_id FROM posts ORDER BY post_timestamp DESC LIMIT 1"
     result = dbutils.execute_fetchone(self.db, query)
     if result is None:
         return result
     ts = result[0]
     channel_id = result[1]
     return {"ts": ts, "channel_id": channel_id}
 def test_post_message_stores_post_date(self, mock_api_call):
     test_ts = "1477581478"
     expected_value = "27/10/16"
     mock_api_call.return_value = {"ts": "1477581478", "channel": "abc123"}
     self.bot.post_message("test_message")
     query = "select rehearsal_date from posts where post_timestamp=(%s)"
     result = dbutils.execute_fetchone(self.test_db, query, (test_ts,))[0]
     self.assertEqual(result, expected_value)
Beispiel #5
0
 def get_timestamp(self, date):
     query = "SELECT post_timestamp FROM posts WHERE rehearsal_date = (%s)"
     result = dbutils.execute_fetchone(self.db, query, (date, ))
     if result is None:
         return result
     return result[0]
 def test_post_message_persists_timestamp(self, mock_api_call):
     mock_api_call.return_value = {"ts": "543210", "channel": "abc123"}
     self.bot.post_message("test_message")
     query = "SELECT * FROM posts WHERE post_timestamp='543210'"
     result = dbutils.execute_fetchone(self.test_db, query)
     self.assertIsNotNone(result)
 def test_set_ignore(self):
     test_id = "12345"
     self.bot.set_ignore(test_id, True)
     query = "SELECT ignore FROM members WHERE slack_id=(%s)"
     res = dbutils.execute_fetchone(self.test_db, query, (test_id,))[0]
     self.assertTrue(res)