Beispiel #1
0
 def testFetchMostRecentGraphSeries_MissingType(self):
   graph_series = _CreateNDayActiveGraphSeries(1)[0]
   client_report_utils.WriteGraphSeries(graph_series, _TEST_LABEL)
   self.assertIsNotNone(
       client_report_utils.FetchMostRecentGraphSeries(
           _TEST_LABEL, rdf_stats.ClientGraphSeries.ReportType.N_DAY_ACTIVE))
   self.assertIsNone(
       client_report_utils.FetchMostRecentGraphSeries(
           _TEST_LABEL, rdf_stats.ClientGraphSeries.ReportType.OS_TYPE))
Beispiel #2
0
  def _CheckAccessStats(self, label, expected):
    graph_series = client_report_utils.FetchMostRecentGraphSeries(
        label, rdf_stats.ClientGraphSeries.ReportType.N_DAY_ACTIVE)

    histogram = graph_series.graphs[0]

    data = [(x.x_value, x.y_value) for x in histogram]

    self.assertEqual(data, expected)
Beispiel #3
0
 def testFetchMostRecentGraphSeries_SingleGraph(self):
   graph_series_list = _CreateNDayActiveGraphSeries(2)
   with test_lib.FakeTime(rdfvalue.RDFDatetime(1000)):
     client_report_utils.WriteGraphSeries(graph_series_list[0], _TEST_LABEL)
   with test_lib.FakeTime(rdfvalue.RDFDatetime(2000)):
     client_report_utils.WriteGraphSeries(graph_series_list[1], _TEST_LABEL)
   self.assertEqual(
       client_report_utils.FetchMostRecentGraphSeries(
           _TEST_LABEL, rdf_stats.ClientGraphSeries.ReportType.N_DAY_ACTIVE),
       graph_series_list[1])
Beispiel #4
0
 def testFetchMostRecentGraphSeries_MultipleGraphs(self):
   graph_series_list = _CreateGRRVersionGraphSeries(2)
   with test_lib.FakeTime(rdfvalue.RDFDatetime(1000)):
     client_report_utils.WriteGraphSeries(graph_series_list[0], _TEST_LABEL)
   with test_lib.FakeTime(rdfvalue.RDFDatetime(2000)):
     client_report_utils.WriteGraphSeries(graph_series_list[1], _TEST_LABEL)
   self.assertEqual(
       client_report_utils.FetchMostRecentGraphSeries(
           _TEST_LABEL, rdf_stats.ClientGraphSeries.ReportType.GRR_VERSION),
       graph_series_list[1])
Beispiel #5
0
  def _CheckOSStats(self, label, report_type, counts):
    # We expect to have 1, 7, 14 and 30-day graphs for every label.
    graph_series = client_report_utils.FetchMostRecentGraphSeries(
        label, report_type)

    self._CheckOSGraph(graph_series.graphs[0],
                       "1 day actives for %s label" % label, counts[0])
    self._CheckOSGraph(graph_series.graphs[1],
                       "7 day actives for %s label" % label, counts[1])
    self._CheckOSGraph(graph_series.graphs[2],
                       "14 day actives for %s label" % label, counts[2])
    self._CheckOSGraph(graph_series.graphs[3],
                       "30 day actives for %s label" % label, counts[3])
Beispiel #6
0
    def GetReportData(self, get_report_args, token):
        """Extract only the operating system type from the active histogram."""
        report = rdf_report_plugins.ApiReportData(
            representation_type=rdf_report_plugins.ApiReportData.
            RepresentationType.PIE_CHART)

        graph_series = client_report_utils.FetchMostRecentGraphSeries(
            get_report_args.client_label,
            rdf_stats.ClientGraphSeries.ReportType.OS_RELEASE)
        if graph_series is not None:
            for graph in graph_series.graphs:
                # Find the correct graph and merge the OS categories together
                if "%s day" % self.__class__.ACTIVE_DAYS in graph.title:
                    for sample in graph:
                        report.pie_chart.data.Append(
                            rdf_report_plugins.ApiReportDataPoint1D(
                                label=sample.label, x=sample.y_value))
                    break
        report.pie_chart.data = sorted(report.pie_chart.data,
                                       key=lambda point: point.label)
        return report
Beispiel #7
0
 def testMostRecentGraphSeries_NonExistentLabel(self):
   self.assertIsNone(
       client_report_utils.FetchMostRecentGraphSeries(
           "nonexistent", rdf_stats.ClientGraphSeries.ReportType.N_DAY_ACTIVE))