Exemplo n.º 1
0
    def test_algorithm1(self):

        for service in self.services:
            messages = self.db.messageByService(service)

            for message in messages:
                self.assertEqual(message["service"], service)

            messages.rewind()

            num = Algorithm1.getAlgorithmNumber()
            res = Algorithm1.getResult(messages)
            self.assertIsInstance(num, int)
            self.assertIsInstance(res, float)
Exemplo n.º 2
0
from database.MongoInterface import MongoInterface
from algorithms.Algorithm1 import Algorithm1
from algorithms.Algorithm2 import Algorithm2
from algorithms.Algorithm3 import Algorithm3
import time

db = MongoInterface()
total = 0
now = time.time()
services = ["Twitter", "Google Plus", "Facebook", "Reddit"]

for service in services:
    messages = db.messageByService(service)
    res = Algorithm1.getResult(messages)
    db.saveResult(now, service, Algorithm1.getAlgorithmNumber(), res)
    total += res

print total

total = 0

for service in services:
    messages = db.messageByService(service)
    res = Algorithm2.getResult(messages)
    db.saveResult(now, service, Algorithm2.getAlgorithmNumber(), res)
    total += res

print total

total = 0