def testForDates(self): prepareDb() logList = list(getLog(DB, 10, None, None, None)) for i in range(len(logList) - 1): self.assertTrue(logList[i][DATE] > logList[i + 1][DATE]) logList = list(getLog(DB, 10, None, DATE_FROM, DATE_TO)) for i in range(len(logList) - 1): self.assertTrue(logList[i][DATE] > logList[i + 1][DATE]) logList = list(getLog(DB, 10, None, DATE_FROM, None)) for i in range(len(logList) - 1): self.assertTrue(logList[i][DATE] > logList[i + 1][DATE]) logList = list(getLog(DB, 10, None, None, DATE_TO)) for i in range(len(logList) - 1): self.assertTrue(logList[i][DATE] > logList[i + 1][DATE])
def get(self): parser_dict = AdminLogParser.parseGetParameters() getLog(parser_dict[SERVICE], parser_dict[NUMBER], parser_dict[OFFSET], dateDeserialiser( parser_dict, DATE_FROM), dateDeserialiser( parser_dict, DATE_TO), parser_dict[SUBSTRING]) return make_response( render_template( 'log.html'))
def testForTestserviceDb(self): collection_testservice.insert({ USER_ID: USER_TESTSERVICE_ID_VALUE, "date": DATE_ISERT }) log_data = list(getLog(DB_TESTSERVICE, 0, 0, DATE_FROM, DATE_TO)) self.assertEqual(log_data[0][USER_ID], USER_TESTSERVICE_ID_VALUE)
def testForGeomongoDb(self): collection_geomongo.insert({ USER_ID: USER_GEOMONGO_ID_VALUE, "date": DATE_ISERT }) log_data = list(getLog(DB_GEOMONGO, 0, 0, DATE_FROM, DATE_TO)) self.assertEqual(log_data[0][USER_ID], USER_GEOMONGO_ID_VALUE)
def get(self, serviceName=None): parser_dict = LogParser.parseGetParameters() if serviceName is None: serviceName = getDbName() return getLog(serviceName, parser_dict[NUMBER], parser_dict[OFFSET], dateDeserialiser(parser_dict, DATE_FROM), dateDeserialiser(parser_dict, DATE_TO))
def get(self, serviceName=None): parser_dict = LogParser.parseGetParameters() if serviceName is None: serviceName = getDbName() return getLog( serviceName, parser_dict[NUMBER], parser_dict[OFFSET], dateDeserialiser( parser_dict, DATE_FROM), dateDeserialiser( parser_dict, DATE_TO))
def testForDates(self): print "Test for dates" prepareDb() # Test when dateFrom and dateTo vars are equal to None self.assertEqual(len(list(getLog(DB, 1, None, None, None))), 1) # Test when dateTo is equal to None log = getLog(DB, None, None, DATE_FROM, None) self.assertTrue(log.count(True) > 0) # Test when dateFrom is equal to None log = getLog(DB, None, None, None, DATE_TO) self.assertTrue(log.count(True) > 0) # Test when dateTo is lower than dateFrom self.assertEqual(getLog(DB, None, None, WRONG_DATE_FROM, DATE_TO), []) # Test when dateTo and dateFrom are normal log = getLog(DB, None, None, DATE_FROM, DATE_TO) self.assertTrue(log.count(True) > 0) # Test when dateTo and dateFrom are normal log = getLog(DB, None, None, WRONG_DATE_FROM, WRONG_DATE_TO) self.assertTrue(log.count(True) == 0)
def testForDates(self): print "Test for dates" prepareDb() # Test when dateFrom and dateTo vars are equal to None self.assertEqual(getLog(DB, None, None, None, None), []) # Test when dateTo is equal to None log = getLog(DB, None, None, DATE_FROM, None) self.assertTrue(log.count(True) > 0) # Test when dateFrom is equal to None log = getLog(DB, None, None, None, DATE_TO) self.assertTrue(log.count(True) > 0) # Test when dateTo is lower than dateFrom self.assertEqual(getLog(DB, None, None, WRONG_DATE_FROM, DATE_TO), []) # Test when dateTo and dateFrom are normal log = getLog(DB, None, None, DATE_FROM, DATE_TO) self.assertTrue(log.count(True) > 0) # Test when dateTo and dateFrom are normal log = getLog(DB, None, None, WRONG_DATE_FROM, WRONG_DATE_TO) self.assertTrue(log.count(True) == 0)
def testSearchLogForSubstr(self): addLogEntry(TEST_DB, TEST_USER_ID, TEST_MSG, LOG_LVL_INFO) result = list(getLog(TEST_DB, 1, 0, None, None, SUBSTRING))[0] self.assertEqual(result[TEST_MSG_FIELD], TEST_MSG)
def testForNoneDb(self): self.assertEqual( len(list((getLog(FAKE_DB, 0, 0, DATE_FROM, DATE_TO)))), 0)
def testForTestserviceDb(self): collection_testservice.insert( {USER_ID: USER_TESTSERVICE_ID_VALUE, "date": DATE_ISERT}) log_data = list(getLog(DB_TESTSERVICE, 0, 0, DATE_FROM, DATE_TO)) self.assertEqual(log_data[0][USER_ID], USER_TESTSERVICE_ID_VALUE)
def testForGeomongoDb(self): collection_geomongo.insert( {USER_ID: USER_GEOMONGO_ID_VALUE, "date": DATE_ISERT}) log_data = list(getLog(DB_GEOMONGO, 0, 0, DATE_FROM, DATE_TO)) self.assertEqual(log_data[0][USER_ID], USER_GEOMONGO_ID_VALUE)