Exemplo n.º 1
0
    def test_basic_response(self):
        jr = RunProgramMetricsReport(self.cohort.id,
                                     parse_pretty_date('2015-01-01 00:00:00'),
                                     parse_pretty_date('2015-01-31 00:00:00'),
                                     self.owner_user_id)
        results = jr.task.delay(jr).get()
        self.session.commit()
        
        # Make sure the cohort is validated
        assert_true(self.cohort.validated)

        result_key = self.session.query(ReportStore) \
            .get(jr.persistent_id) \
            .result_key
        results = results[result_key]
        assert_equals(
            len(results[Aggregation.SUM]),
            6)
        assert_equals(
            results[Aggregation.SUM]['pages_created'], 1)
        assert_equals(
            results[Aggregation.SUM]['pages_edited'], 4)
        assert_equals(
            results[Aggregation.SUM]['newly_registered'], 0)
        assert_equals(
            results[Aggregation.SUM]['existing_editors'], 5)
        assert_equals(
            results[Aggregation.SUM]['rolling_active_editor'], 0)
        assert_equals(
            results[Aggregation.SUM]['bytes_added'], 10)
Exemplo n.º 2
0
 def test_raises_unvalidated_cohort(self):
     self.cohort.validated = False
     jr = RunProgramMetricsReport(self.cohort.id,
                                  parse_pretty_date('2015-01-01 00:00:00'),
                                  parse_pretty_date('2015-01-31 00:00:00'),
                                  self.owner_user_id)
     jr.task.delay(jr).get()
Exemplo n.º 3
0
 def test_invalid_cohort_returns_failure(self):
     self.cohort.validated = True
     wikiusers = self.session.query(WikiUserStore) \
         .filter(WikiUserStore.validating_cohort == self.cohort.id) \
         .all()
     # Valid cohorts have >=50% of the users valid, so we make half
     # of them invalid to test
     for wu in wikiusers[:(len(wikiusers) / 2 + 1)]:
         wu.valid = False
     self.session.commit()
     jr = RunProgramMetricsReport(self.cohort.id,
                                  parse_pretty_date('2015-01-01 00:00:00'),
                                  parse_pretty_date('2015-01-31 00:00:00'),
                                  self.owner_user_id)
     results = jr.task.delay(jr).get()
     self.session.commit()
     result_key = self.session.query(ReportStore) \
         .get(jr.persistent_id) \
         .result_key
     results = results[result_key]
     assert_is_not_none(results['FAILURE'])
 def test_parse_pretty_date(self):
     date = datetime.datetime(2012, 2, 3, 4, 5)
     assert_equal(date, parse_pretty_date(format_pretty_date(date)))
 def test_parse_pretty_date(self):
     date = datetime(2012, 2, 3, 4, 5)
     assert_equal(date, parse_pretty_date(format_pretty_date(date)))