Skip to content

Commit

Permalink
Add a disabled exporter to our test case
Browse files Browse the repository at this point in the history
To ensure that disabled exporters are not rendered, we want to update
our fixture with a disabled exporter, and ensure the rest of the tests
still work.
  • Loading branch information
kfdm committed Jul 25, 2024
1 parent 8448517 commit 5df9f4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions promgen/fixtures/testcases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@
project: 1
job: node
port: 9100
- model: promgen.exporter
pk: 2
fields:
project: 2
job: node
port: 9100
enabled: false
6 changes: 3 additions & 3 deletions promgen/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def test_register_job(self, mock_signal):
management.call_command("register-job", "test-project", "example", 1234)

# Ensure the jobs we expect exist
self.assertCount(models.Exporter, 2, "Import a new exporter")
self.assertCount(models.Exporter, 3, "Import a new exporter")

# Registering the same job again shouldn't change our count
management.call_command("register-job", "test-project", "example", 1234)
self.assertCount(models.Exporter, 2, "Import additional exporter")
self.assertCount(models.Exporter, 3, "Import additional exporter")

# But registering a new one will
management.call_command("register-job", "test-project", "example", 4321)
self.assertCount(models.Exporter, 3, 'Import additional exporter')
self.assertCount(models.Exporter, 4, 'Import additional exporter')

@mock.patch("promgen.signals._trigger_write_config")
def test_register_host(self, mock_signal):
Expand Down
4 changes: 2 additions & 2 deletions promgen/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_import(self, mock_write, mock_reload):
self.assertRoute(response, views.Import, 302, "Redirect to imported object")
self.assertCount(models.Service, 3, "Import one service (Fixture has two services)")
self.assertCount(models.Project, 4, "Import two projects")
self.assertCount(models.Exporter, 3, "Import two more exporters")
self.assertCount(models.Exporter, 4, "Import two more exporters")
self.assertCount(models.Host, 3, "Import three hosts")

@override_settings(PROMGEN=TEST_SETTINGS)
Expand All @@ -50,7 +50,7 @@ def test_replace(self, mock_write, mock_reload):

self.assertCount(models.Service, 3, "Import one service (Fixture has two services)")
self.assertCount(models.Project, 4, "Import two projects (Fixture has 2 projectsa)")
self.assertCount(models.Exporter, 3, "Import two more exporters")
self.assertCount(models.Exporter, 4, "Import two more exporters")
self.assertCount(
models.Farm, 4, "Original two farms and one new farm (fixture has one farm)"
)
Expand Down

0 comments on commit 5df9f4e

Please sign in to comment.