Beispiel #1
0
    def test_create_datasource(self, mock_grafana):
        path = os.path.join(
            os.path.dirname(__file__), 'fixtures/builder/datasource-0001.yaml')

        # Create a datasource.
        self._create_datasource(path)
        # Create a new builder to avoid duplicate datasources.
        builder2 = builder.Builder(self.config)
        # Update again with same datasource, ensure we don't update grafana.
        builder2.update(path)
        self.assertEqual(mock_grafana.call_count, 0)
Beispiel #2
0
    def test_delete_dashboard(self, mock_grafana):
        path = os.path.join(
            os.path.dirname(__file__), 'fixtures/builder/dashboard-0001.yaml')

        # Create a dashboard.
        self._update_dashboard(path)
        # Create a new builder to avoid duplicate dashboards.
        builder2 = builder.Builder(self.config)
        # Delete same dashboard, ensure we delete it from grafana.
        builder2.delete(path)
        self.assertEqual(mock_grafana.call_count, 1)
Beispiel #3
0
    def test_update_dashboard(self, mock_grafana):
        path = os.path.join(
            os.path.dirname(__file__), "fixtures/builder/dashboard-0001.yaml"
        )

        # Create a dashboard.
        self._update_dashboard(path)
        # Create a new builder to avoid duplicate dashboards.
        builder2 = builder.Builder(self.config)
        # Update again with same dashboard, ensure we don't update grafana.
        builder2.update(path)
        self.assertEqual(mock_grafana.call_count, 0)
Beispiel #4
0
    def test_update_datasource(self, mock_is_datasource, mock_update):
        path = os.path.join(
            os.path.dirname(__file__), 'fixtures/builder/datasource-0001.yaml')

        # Create a datasource.
        self._create_datasource(path)
        # Create a new builder to avoid duplicate datasources.
        builder2 = builder.Builder(self.config)

        # Same datasource name, different content.
        path = os.path.join(
            os.path.dirname(__file__), 'fixtures/builder/datasource-0002.yaml')

        # Update again with same datasource, ensure we update grafana.
        builder2.update(path)
        self.assertEqual(mock_is_datasource.call_count, 1)
        self.assertEqual(mock_update.call_count, 1)
Beispiel #5
0
 def setUp(self):
     super(TestCaseBuilder, self).setUp()
     self.builder = builder.Builder(self.config)