コード例 #1
0
ファイル: test_scorer.py プロジェクト: Matt-Gebert/mytardis
    def testScoringWithTimes(self):
        self._setup()
        scorer = MigrationScorer({
                'user_priority_weighting': [5.0, 2.0, 1.0, 0.5, 0.2],
                'file_size_weighting': 1.0,
                'file_access_weighting': 1.0,
                'file_age_weighting': 1.0,
                'file_size_threshold': 0,
                'file_access_threshold': 0,
                'file_age_threshold': 1})
        
        self.assertEquals(0.0, scorer.datafile_score(self.df1))
     
        f = tempfile.NamedTemporaryFile(dir=settings.FILE_STORE_PATH)
        f.write("Hi Mom!!\n")
        self.df1.url = f.name

        self.assertEquals(2.0, scorer.datafile_score(self.df1))
        
        older = time.time() - (60 * 60 * 24 + 300)
        os.utime(f.name, (older, older))

        self.assertEquals(3.0, scorer.datafile_score(self.df1))

        older = time.time() - (60 * 60 * 24 * 2 + 300)
        os.utime(f.name, (older, older))

        self.assertEquals(5.0, scorer.datafile_score(self.df1))

        f.close()
コード例 #2
0
ファイル: test_scorer.py プロジェクト: tjdett/mytardis
    def testScoringWithTimes(self):
        self._setup()
        scorer = MigrationScorer(
            Location.get_location('local').id, {
                'user_priority_weighting': [5.0, 2.0, 1.0, 0.5, 0.2],
                'file_size_weighting': 1.0,
                'file_access_weighting': 1.0,
                'file_age_weighting': 1.0,
                'file_size_threshold': 0,
                'file_access_threshold': 0,
                'file_age_threshold': 1
            })

        self.assertEquals(0.0, scorer.datafile_score(self.df1))

        f = tempfile.NamedTemporaryFile(dir=settings.FILE_STORE_PATH)
        f.write("Hi Mom!!\n")
        rep = Replica.objects.get(pk=self.rep1.pk)
        rep.url = f.name
        rep.save()

        self.assertEquals(2.0, scorer.datafile_score(self.df1))

        older = time.time() - (60 * 60 * 24 + 300)
        os.utime(f.name, (older, older))

        self.assertEquals(3.0, scorer.datafile_score(self.df1))

        older = time.time() - (60 * 60 * 24 * 2 + 300)
        os.utime(f.name, (older, older))

        self.assertEquals(5.0, scorer.datafile_score(self.df1))

        f.close()
コード例 #3
0
ファイル: migratefiles.py プロジェクト: Matt-Gebert/mytardis
 def _do_score_all(self):
     scorer = MigrationScorer(settings.MIGRATION_SCORING_PARAMS)
     return scorer.score_all_datafiles()
コード例 #4
0
ファイル: test_scorer.py プロジェクト: Matt-Gebert/mytardis
 def testScoring(self):
     self._setup()
     scorer = MigrationScorer()
     self.assertEquals(2.0, scorer.datafile_score(self.df1))
     self.assertEquals(2, get_user_priority(self.user1))
     self.assertEquals(1, get_user_priority(self.user2))
     self.assertEquals(1.0, scorer.user_score(self.user1))
     self.assertEquals(2.0, scorer.user_score(self.user2))
     self.assertEquals(2.0, scorer.experiment_score(self.exp1))
     self.assertEquals(2.0, scorer.dataset_score(self.df1.dataset))
     self.assertEquals(4.0, scorer.score_datafile(self.df1))
     self.assertEquals([(self.df1, 4.0)], 
                       scorer.score_datafiles_in_dataset(self.ds1))
     self.assertEquals([(self.df5, 8.0), (self.df4, 6.0), (self.df1, 4.0)],
                       scorer.score_datafiles_in_experiment(self.exp1))
     self.assertEquals([(self.df5, 8.0), (self.df4, 6.0)],
                       scorer.score_datafiles_in_experiment(self.exp2))
     self.assertEquals([(self.df6, 5.0)],
                       scorer.score_datafiles_in_experiment(self.exp3))
     self.assertEquals([(self.df5, 8.0), (self.df4, 6.0), (self.df6, 5.0), 
                        (self.df1, 4.0), (self.df7, 0.0), (self.df8, 0.0)],
                       scorer.score_all_datafiles())
     self.assertEquals([(self.df7, 0.0), (self.df8, 0.0)], 
                       scorer.score_datafiles_in_dataset(self.ds4))
コード例 #5
0
ファイル: migratefiles.py プロジェクト: tjdett/mytardis
 def _do_score_all(self):
     scorer = MigrationScorer(self.source.id,
                              settings.MIGRATION_SCORING_PARAMS)
     return scorer.score_all_datafiles()
コード例 #6
0
ファイル: test_scorer.py プロジェクト: tjdett/mytardis
 def testScoring(self):
     self._setup()
     scorer = MigrationScorer(Location.get_location('local').id)
     self.assertEquals(2.0, scorer.datafile_score(self.df1))
     self.assertEquals(2, get_user_priority(self.user1))
     self.assertEquals(1, get_user_priority(self.user2))
     self.assertEquals(1.0, scorer.user_score(self.user1))
     self.assertEquals(2.0, scorer.user_score(self.user2))
     self.assertEquals(2.0, scorer.experiment_score(self.exp1))
     self.assertEquals(2.0, scorer.dataset_score(self.df1.dataset))
     self.assertEquals(4.0, scorer.score_datafile(self.df1))
     self.assertEquals([(self.df1, self.rep1, 4.0)],
                       scorer.score_datafiles_in_dataset(self.ds1))
     self.assertEquals([(self.df5, self.rep5, 8.0),
                        (self.df4, self.rep4, 6.0),
                        (self.df1, self.rep1, 4.0)],
                       scorer.score_datafiles_in_experiment(self.exp1))
     self.assertEquals([(self.df5, self.rep5, 8.0),
                        (self.df4, self.rep4, 6.0)],
                       scorer.score_datafiles_in_experiment(self.exp2))
     self.assertEquals([(self.df6, self.rep6, 5.0)],
                       scorer.score_datafiles_in_experiment(self.exp3))
     self.assertEquals([(self.df5, self.rep5, 8.0),
                        (self.df4, self.rep4, 6.0),
                        (self.df6, self.rep6, 5.0),
                        (self.df1, self.rep1, 4.0),
                        (self.df7, self.rep7, 0.0),
                        (self.df8, self.rep8, 0.0)],
                       scorer.score_all_datafiles())
     self.assertEquals([(self.df7, self.rep7, 0.0),
                        (self.df8, self.rep8, 0.0)],
                       scorer.score_datafiles_in_dataset(self.ds4))