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
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()
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()
def __init__(self): super(ShowableGraphDAO, self).__init__(Mongo().get().db.showable_graphs) self.logger = Logger(self.__class__.__name__)
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()
def __init__(self): super(PartyRelationshipsDAO, self).__init__(Mongo().get().db.party_relationships) self.logger = Logger(self.__class__.__name__)
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)])
def __init__(self): super(CandidatesFollowersDAO, self).__init__(Mongo().get().db.candidates_followers) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(UsersFriendsDAO, self).__init__(Mongo().get().db.users_friends) self.logger = Logger(self.__class__.__name__)
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)])
def __init__(self): super(CooccurrenceGraphDAO, self).__init__(Mongo().get().db.cooccurrence_graphs) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(HashtagEntropyDAO, self).__init__(Mongo().get().db.hashtag_entropy) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(DashboardDAO, self).__init__(Mongo().get().db.dashboard) self.logger = Logger(self.__class__.__name__)
def setUp(self) -> None: super(TestUserNetworkRetrievalService, self).setUp() Mongo().db = mongomock.database.Database(mongomock.MongoClient(), 'elections', _store=None)
def setUp(self) -> None: super(TestRawTweetDAO, self).setUp() Mongo().db = mongomock.database.Database(mongomock.MongoClient(), 'elections', _store=None) self.target = RawTweetDAO()
def __init__(self): super(RawTweetDAO, self).__init__(Mongo().get().db.raw_tweets) # self.__dict__.update(**kwargs) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(HashtagsTopicsDAO, self).__init__(Mongo().get().db.hashtags_topics) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(CommunityStrengthDAO, self).__init__(Mongo().get().db.community_strength) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(TopicUsageDAO, self).__init__(Mongo().get().db.topic_usage) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(HashtagUsageDAO, self).__init__(Mongo().get().db.hashtag_usage) self.logger = Logger(self.__class__.__name__)
def __init__(self): super(SimilarityDAO, self).__init__(Mongo().get().db.users_similarities) self.logger = Logger(self.__class__.__name__)
def setUp(self) -> None: super(TestCandidatesFollowersDAO, self).setUp() Mongo().db = mongomock.database.Database(mongomock.MongoClient(), 'elections', _store=None) self.target = CandidatesFollowersDAO()
def __init__(self): super(RawFollowerDAO, self).__init__(Mongo().get().db.raw_followers) self.logger = Logger(self.__class__.__name__)
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)