Exemple #1
0
 def testDeletePlot(self):
     """
     Tests deleting a single saved plot
     """
     new_files = generateDocs(PlotTest.account_id, 1, 4, 3)
     PlotTest.files.extend(new_files)
     plot_args = {
         'type' : 'scatter',
         'title': PlotTest.testSavePlot.__name__,
         'x_label': 'x',
         'y_label': 'y',
         'x_points': {'file_name': "test1", 'header_name': "c0", 'owner_id': PlotTest.account_id},
         'y_points': [
             {'file_name': "test1", 'header_name': "c1", 'owner_id': PlotTest.account_id},
             {'file_name': "test1", 'header_name': "c2", 'owner_id': PlotTest.account_id}
         ]
     }
     details = PlotDetails(
         plot_args['type'],
         plot_args['title'],
         plot_args['x_label'],
         plot_args['y_label'],
         plot_args['x_points'],
         plot_args['y_points'],
     )
     Plot.save_plot(PlotTest.account_id, details)
     self.assertEqual(1, Plot.objects.all().count())
     plot_id = Plot.objects.get(account_id=PlotTest.account_id).id
     Plot.remove_user_plot(plot_id)
     self.assertEqual(0, Plot.objects.all().count())
Exemple #2
0
    def testSavePlot(self):
        """
        Tests saving a single plot
        """
        new_files = generateDocs(PlotTest.account_id, 1, 4, 3)
        PlotTest.files.extend(new_files)
        plot_args = {
            'type' : 'SCATTER3D',
            'title': PlotTest.testSavePlot.__name__,
            'x_label': 'x',
            'y_label': 'y',
            'x_points': ['test1', 'c0'],
            'y_points': [['test1', 'c1'], ['test1', 'c2']],
        }
        details = PlotDetails(
            plot_args['type'],
            plot_args['title'],
            plot_args['x_label'],
            plot_args['y_label'],
            plot_args['x_points'],
            plot_args['y_points'],
        )
        Plot.save_plot(PlotTest.account_id, details)
        saved_plot = Plot.objects.get(account_id=PlotTest.account_id)
        # self.assertEqual(plot_args['account'], saved_plot.account_id)

        self.assertEqual(details.plot_type, saved_plot.plot_type)
        self.assertEqual(details.plot_title, saved_plot.plot_title)
        self.assertEqual(details.x_label, saved_plot.x_label)
        self.assertEqual(details.y_label, saved_plot.y_label)
        self.assertEqual(details.x_points, ast.literal_eval(saved_plot.x_points))
        self.assertEqual(details.y_points, ast.literal_eval(saved_plot.y_points))
Exemple #3
0
 def testGetUserPlots(self):
     """
     Tests that correct number of user plots are returned
     """
     new_files = generateDocs(PlotTest.account_id, 1, 4, 4)
     PlotTest.files.extend(new_files)
     plot_args = {
         'type' : 'scatter',
         'title': PlotTest.testSavePlot.__name__,
         'x_label': 'x',
         'y_label': 'y',
         'x_points': {'file_name': 'test1', 'header_name': 'c0', 'owner_id': PlotTest.account_id},
         'y_points': [
             {'file_name': 'test1', 'header_name': 'c1', 'owner_id': PlotTest.account_id},
             {'file_name': 'test1', 'header_name': 'c2', 'owner_id': PlotTest.account_id}
         ],
     }
     details = PlotDetails(
         plot_args['type'],
         plot_args['title'],
         plot_args['x_label'],
         plot_args['y_label'],
         plot_args['x_points'],
         plot_args['y_points'],
     )
     DFACTOR=3
     for _ in range(DFACTOR):
         Plot.save_plot(PlotTest.account_id, details)
     self.assertEqual(DFACTOR, len(Plot.get_user_plots(PlotTest.account_id)))