def testGetRunningStatesForDomain(self): with open(join(self.stateDir, self.domainId, "repoId1.running"), 'w') as fp: jsonDump( { 'changedate': "2012-08-14 12:00:00", 'status': "Ok", 'message': "" }, fp) with open(join(self.stateDir, self.domainId, "repoId3.running"), 'w') as fp: jsonDump( { 'changedate': "2012-08-13 12:00:00", 'status': "Error", 'message': "an error message" }, fp) with open(join(self.stateDir, self.domainId, "anotherRepoId.running"), 'w') as fp: jsonDump( { 'changedate': "2012-08-16 12:00:00", 'status': "Ok", 'message': "" }, fp) expected = [ { 'repositoryId': 'anotherRepoId', 'changedate': "2012-08-16 12:00:00", 'status': "Ok", 'message': "" }, { 'repositoryId': 'repoId1', 'changedate': "2012-08-14 12:00:00", 'status': "Ok", 'message': "" }, { 'repositoryId': 'repoId3', 'changedate': "2012-08-13 12:00:00", 'status': "Error", 'message': "an error message" }, ] self.assertEqual(expected, self.status.getRunningStatesForDomain(self.domainId))
def testGetRunningStatesForDomain(self): jsonDump( {'changedate': "2012-08-14 12:00:00",'status': "Ok", 'message': ""}, open(join(self.stateDir, self.domainId, "repoId1.running"), 'w') ) jsonDump( {'changedate': "2012-08-13 12:00:00",'status': "Error", 'message': "an error message"}, open(join(self.stateDir, self.domainId, "repoId3.running"), 'w') ) jsonDump( {'changedate': "2012-08-16 12:00:00",'status': "Ok", 'message': ""}, open(join(self.stateDir, self.domainId, "anotherRepoId.running"), 'w') ) expected = [ {'repositoryId': 'anotherRepoId', 'changedate': "2012-08-16 12:00:00",'status': "Ok", 'message': ""}, {'repositoryId': 'repoId1', 'changedate': "2012-08-14 12:00:00",'status': "Ok", 'message': ""}, {'repositoryId': 'repoId3', 'changedate': "2012-08-13 12:00:00",'status': "Error", 'message': "an error message"}, ] self.assertEquals(expected, self.status.getRunningStatesForDomain(self.domainId))
def _createServer(self, stateDir, port, config): solrConfFile = join(self.tempdir, 'solr.conf') jsonDump(config, open(solrConfFile, 'w')) return Server(stateDir, port, solrConfFile)
def _markRunningState(self, status, message=""): runningDict = jsonLoad(open(self._runningFilename)) if isfile(self._runningFilename) else {} if status != runningDict.get('status', None) or message != runningDict.get('message', None): jsonDump({'changedate': self.getTime(),'status': status, 'message': message}, open(self._runningFilename, 'w'))
def _writeResumptionValues(self, token, responseDate): newToken = str(token or '') newFrom = '' if responseDate: newFrom = self.from_ if self.token else responseDate jsonDump({'resumptionToken': newToken, 'from': newFrom}, open(self._resumptionFilename, 'w'))