def test_get_all(self):

        PROJECT_NAME = 'test project get_all'

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dto2 = ProjectMetaDataDto(PROJECT_NAME + "2")
        project_dto2.last_fetch = datetime.datetime.now()
        project_dto2.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        project_dao.put(project_dto2)

        project_dtos = project_dao.get_all()
        project_dao.close()
        self.assertEquals(2, len(project_dtos))
    def test_delete_last_fetch(self):

        PROJECT_NAME = 'test project delete'
        DAYS = 90

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dto2 = ProjectMetaDataDto(PROJECT_NAME + "2")
        project_dto2.last_fetch = datetime.datetime.now() - timedelta(days=DAYS + 5)
        project_dto2.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        project_dao.put(project_dto2)

        project_dao.delete_last_fetch(DAYS)
        project_dtos = project_dao.get_all()
        project_dao.close()
        self.assertEquals(1, len(project_dtos))
    def test_put_newvalue(self):

        PROJECT_NAME = 'test project'

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        read_project_dto = project_dao.get(PROJECT_NAME)

        self.assertEquals(PROJECT_NAME, read_project_dto.name)
Exemple #4
0
    def test_put_newvalue(self):

        PROJECT_NAME = 'test project'

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        read_project_dto = project_dao.get(PROJECT_NAME)

        self.assertEquals(PROJECT_NAME, read_project_dto.name)
    def test_put_updatevalue(self):

        PROJECT_NAME = 'test project update'
        WORDS = 100

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        project_dto.words = WORDS
        project_dao.put(project_dto)

        read_project_dto = project_dao.get(PROJECT_NAME)

        self.assertEquals(WORDS, read_project_dto.words)
Exemple #6
0
    def test_put_updatevalue(self):

        PROJECT_NAME = 'test project update'
        WORDS = 100

        project_dto = ProjectMetaDataDto(PROJECT_NAME)
        project_dto.last_fetch = datetime.datetime.now()
        project_dto.last_translation_update = datetime.datetime.now()

        project_dao = ProjectMetaDataDao()
        project_dao.open(':memory:')
        project_dao.put(project_dto)
        project_dto.words = WORDS
        project_dao.put(project_dto)

        read_project_dto = project_dao.get(PROJECT_NAME)

        self.assertEquals(WORDS, read_project_dto.words)
 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_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)