-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove middleware
- Loading branch information
Showing
4 changed files
with
23 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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') | ||
|
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.