Exemple #1
0
 def setUp(self) -> None:
     super(TestHashtagOriginService, self).setUp()
     # We need this to avoid mocking some object creations
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(),
                                              'elections',
                                              _store=None)
     self.target = HashtagOriginService
Exemple #2
0
def set_up_context(db_name, authorization, environment):
    # Configure logger
    Logger.set_up(environment)
    Logger(__name__).info(f'Starting application in environment {environment}')
    # Configure database
    app.config['MONGO_DBNAME'] = db_name
    app.config[
        'MONGO_URI'] = f'mongodb://{authorization}localhost:27017/{db_name}'
    Mongo().db.init_app(app)
    with app.app_context():
        create_indexes()
Exemple #3
0
 def setUp(self) -> None:
     super(TestCandidateService, self).setUp()
     # Mocking the whole database is not unit testing but we don't care because this is done to only to
     # make target's initialization easier
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(),
                                              'elections',
                                              _store=None)
     # Now we override whatever the DB would answer
     candidate1 = Candidate(**{'screen_name': 'sn1', 'nickname': 'n1'})
     candidate2 = Candidate(**{'screen_name': 'sn2', 'nickname': 'n2'})
     CandidateService().candidates = [candidate1, candidate2]
     # Get the object
     self.target = CandidateService()
Exemple #4
0
 def __init__(self):
     super(ShowableGraphDAO,
           self).__init__(Mongo().get().db.showable_graphs)
     self.logger = Logger(self.__class__.__name__)
Exemple #5
0
 def setUp(self) -> None:
     super(TestFollowerUpdateService, self).setUp()
     # We need this to avoid mocking some object creations
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(), 'elections', _store=None)
     FollowerUpdateHelper.restart_all_iterations()
Exemple #6
0
 def __init__(self):
     super(PartyRelationshipsDAO,
           self).__init__(Mongo().get().db.party_relationships)
     self.logger = Logger(self.__class__.__name__)
Exemple #7
0
 def create_indexes(self):
     self.logger.info(
         'Creating has_tweets index for collection raw_followers.')
     Mongo().get().db.raw_followers.create_index([('has_tweets',
                                                   pymongo.DESCENDING)])
Exemple #8
0
 def __init__(self):
     super(CandidatesFollowersDAO,
           self).__init__(Mongo().get().db.candidates_followers)
     self.logger = Logger(self.__class__.__name__)
Exemple #9
0
 def __init__(self):
     super(UsersFriendsDAO, self).__init__(Mongo().get().db.users_friends)
     self.logger = Logger(self.__class__.__name__)
Exemple #10
0
 def create_indexes(self):
     self.logger.info('Creating topic_id index for collection cooccurrence_graphs.')
     Mongo().get().db.cooccurrence_graphs.create_index([('topic_id', pymongo.DESCENDING)])
Exemple #11
0
 def __init__(self):
     super(CooccurrenceGraphDAO, self).__init__(Mongo().get().db.cooccurrence_graphs)
     self.logger = Logger(self.__class__.__name__)
Exemple #12
0
 def __init__(self):
     super(HashtagEntropyDAO,
           self).__init__(Mongo().get().db.hashtag_entropy)
     self.logger = Logger(self.__class__.__name__)
Exemple #13
0
 def __init__(self):
     super(DashboardDAO, self).__init__(Mongo().get().db.dashboard)
     self.logger = Logger(self.__class__.__name__)
Exemple #14
0
 def setUp(self) -> None:
     super(TestUserNetworkRetrievalService, self).setUp()
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(),
                                              'elections',
                                              _store=None)
Exemple #15
0
 def setUp(self) -> None:
     super(TestRawTweetDAO, self).setUp()
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(),
                                              'elections',
                                              _store=None)
     self.target = RawTweetDAO()
Exemple #16
0
 def __init__(self):
     super(RawTweetDAO, self).__init__(Mongo().get().db.raw_tweets)
     # self.__dict__.update(**kwargs)
     self.logger = Logger(self.__class__.__name__)
Exemple #17
0
 def __init__(self):
     super(HashtagsTopicsDAO, self).__init__(Mongo().get().db.hashtags_topics)
     self.logger = Logger(self.__class__.__name__)
Exemple #18
0
 def __init__(self):
     super(CommunityStrengthDAO,
           self).__init__(Mongo().get().db.community_strength)
     self.logger = Logger(self.__class__.__name__)
Exemple #19
0
 def __init__(self):
     super(TopicUsageDAO, self).__init__(Mongo().get().db.topic_usage)
     self.logger = Logger(self.__class__.__name__)
Exemple #20
0
 def __init__(self):
     super(HashtagUsageDAO, self).__init__(Mongo().get().db.hashtag_usage)
     self.logger = Logger(self.__class__.__name__)
Exemple #21
0
 def __init__(self):
     super(SimilarityDAO, self).__init__(Mongo().get().db.users_similarities)
     self.logger = Logger(self.__class__.__name__)
Exemple #22
0
 def setUp(self) -> None:
     super(TestCandidatesFollowersDAO, self).setUp()
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(), 'elections', _store=None)
     self.target = CandidatesFollowersDAO()
Exemple #23
0
 def __init__(self):
     super(RawFollowerDAO, self).__init__(Mongo().get().db.raw_followers)
     self.logger = Logger(self.__class__.__name__)
Exemple #24
0
 def setUp(self) -> None:
     super(TestTweetUpdateService, self).setUp()
     # We need this to avoid mocking some object creations
     Mongo().db = mongomock.database.Database(mongomock.MongoClient(),
                                              'elections',
                                              _store=None)