def get(self, name): c = self.connection.cursor() command = u"SELECT * FROM projects WHERE name='{0}'".format(name) result = c.execute(command) row = result.fetchone() if row is None: return None dto = ProjectMetaDataDto(row[0]) dto.last_fetch = row[1] dto.last_translation_update = row[2] dto.words = row[3] dto.checksum = row[4] return dto
def __call__(self): """Process all projects""" for project in self.projects: project.do() words, entries = project.get_words_entries() if words == -1: continue metadata_dto = self.metadata_dao.get(project.name) if metadata_dto is None: metadata_dto = ProjectMetaDataDto(project.name) if (metadata_dto.checksum is None or metadata_dto.checksum != project.checksum): metadata_dto.last_translation_update = datetime.datetime.now() metadata_dto.checksum = project.checksum metadata_dto.last_fetch = datetime.datetime.now() metadata_dto.words = words self.metadata_dao.put(metadata_dto) self.create_tm_for_all_projects()
def test_set_last_fetch_update_wrong_type(self): metadata_dto = ProjectMetaDataDto('') date = 1 with self.assertRaises(TypeError): metadata_dto.last_fetch(date)
def test_set_get_last_fetch(self): DATE = datetime.datetime(2010, 8, 3, 23, 33, 9, 890000) metadata_dto = ProjectMetaDataDto('') metadata_dto.last_fetch = DATE self.assertEquals(DATE, metadata_dto.last_fetch)
def test_set_get_last_translation_update(self): DATE = datetime.datetime(2010, 8, 3, 23, 33, 9, 890000) metadata_dto = ProjectMetaDataDto('') metadata_dto.last_translation_update = DATE self.assertEquals(DATE, metadata_dto.last_translation_update)