Skip to content

Commit

Permalink
Add test for dhcp config format
Browse files Browse the repository at this point in the history
Remove middleware
  • Loading branch information
hipek8 committed Jul 2, 2024
1 parent d4d3ee8 commit 3978c13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 51 deletions.
23 changes: 23 additions & 0 deletions src/ralph/dhcp/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from ddt import data, ddt, unpack
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -61,6 +63,27 @@ class DHCPEntriesViewTest(TestCase):
def setUp(self):
self.view = DHCPEntriesView()

def test_dhcp_entries_are_returned_in_correct_format(self):
get_user_model().objects.create_superuser(
'test', '[email protected]', 'test'
)
self.client.login(username='test', password='test')
network = NetworkFactory(address='192.168.1.0/24')
IPAddressFactory(address='192.168.1.2', dhcp_expose=True)
url = '{}?env={}'.format(
reverse('dhcp_config_entries'), network.network_environment
)
response = self.client.get(url)
lines = response.content.decode().strip().split('\n')
self.assertTrue(lines[0].startswith('# DHCP config generated by Ralph last modified at'))
self.assertTrue(
re.match(
r'^host\s\S+\s\{fixed-address\s192\.168\.1\.2;\shardware\sethernet\s\S*?;\s}$',
lines[2]
)
)
self.assertEqual(len(lines), 4)

def test_get_last_modified_should_return_ip_modified(self):
network = NetworkFactory(address='192.168.1.0/24')
ip = IPAddressFactory(address='192.168.1.2')
Expand Down
Empty file.
5 changes: 0 additions & 5 deletions src/ralph/lib/error_handling/exceptions.py

This file was deleted.

46 changes: 0 additions & 46 deletions src/ralph/lib/error_handling/middleware.py

This file was deleted.

0 comments on commit 3978c13

Please sign in to comment.