Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix cydns tests, fqdn not being set

  • Loading branch information...
commit e7b1f644d306009220894e69c5907b73f65ae824 1 parent da0af6b
Kevin Ngo authored
28 cyder/cydns/tests/test_views.py
View
@@ -28,6 +28,8 @@ def do_setUp(self, url_slug, test_class, test_data, use_domain=True):
class CNAMEViewTests(cyder.base.tests.TestCase):
+ name = 'cname'
+
def setUp(self):
test_data = {
'label': random_label(),
@@ -37,13 +39,16 @@ def setUp(self):
def post_data(self):
return {
- 'label': random_label(),
+ 'fqdn': self.domain.name,
'domain': self.domain.pk,
+ 'label': random_label(),
'target': random_label()
}
class MXViewTests(cyder.base.tests.TestCase):
+ name = 'mx'
+
def setUp(self):
test_data = {
'label': random_label(),
@@ -55,8 +60,9 @@ def setUp(self):
def post_data(self):
return {
- 'label': random_label(),
+ 'fqdn': self.domain.name,
Jacques Uber Collaborator
uberj added a note

Setting fqdn to self.domain.name and at the same time setting label to <something random> and domain to self.domain doesn't make sense.
The fqdn field is calculated (during clean) to equal label + '.' + domain.name. Am I missing something here?

Kevin Ngo Owner

This is formdata, before clean. Fqdn is smartname

Jacques Uber Collaborator
uberj added a note

Ah, okay. That makes more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
'domain': self.domain.pk,
+ 'label': random_label(),
'server': random_label(),
'priority': 123,
'ttl': 213
@@ -64,6 +70,8 @@ def post_data(self):
class SRVViewTests(cyder.base.tests.TestCase):
+ name = 'srv'
+
def setUp(self):
test_data = {
'label': "_" + random_label(),
@@ -76,8 +84,9 @@ def setUp(self):
def post_data(self):
return {
- 'label': "_" + random_label(),
+ 'fqdn': self.domain.name,
'domain': self.domain.pk,
+ 'label': "_" + random_label(),
'target': random_label(),
'priority': 2,
'weight': 2222,
@@ -86,6 +95,8 @@ def post_data(self):
class TXTViewTests(cyder.base.tests.TestCase):
+ name = 'txt'
+
def setUp(self):
test_data = {
'label': random_label(),
@@ -95,13 +106,16 @@ def setUp(self):
def post_data(self):
return {
- 'label': random_label(),
+ 'fqdn': self.domain.name,
'domain': self.domain.pk,
+ 'label': random_label(),
'txt_data': random_label()
}
class SSHFPViewTests(cyder.base.tests.TestCase):
+ name = 'sshfp'
+
def setUp(self):
test_data = {
'label': random_label(),
@@ -113,8 +127,9 @@ def setUp(self):
def post_data(self):
return {
- 'label': random_label(),
+ 'fqdn': self.domain.name,
'domain': self.domain.pk,
+ 'label': random_label(),
'algorithm_number': 1,
'fingerprint_type': 1,
'key': random_label()
@@ -126,4 +141,5 @@ def post_data(self):
for view_test in tests:
builder = GenericViewTests()
for test in builder.build_all_tests():
- setattr(view_test, test.__name__ + "_sshfp", test)
+ # Set name of test.
+ setattr(view_test, test.__name__ + '_' + view_test.name, test)
7 cyder/cydns/tests/test_views_template.py
View
@@ -65,7 +65,7 @@ def test_base_cydns_app(self):
def build_get_create(self):
"""
- List view, get.
+ Create view, get.
"""
def test_get_create(self):
resp = self.client.get(self.test_class.get_create_url(),
@@ -78,9 +78,11 @@ def build_post_create(self):
Create view, post.
"""
def test_post_create(self):
+ count = self.test_class.objects.count()
resp = self.client.post(self.test_class.get_create_url(),
self.post_data(), follow=True)
self.assertTrue(resp.status_code in (302, 200))
+ self.assertTrue(self.test_class.objects.count() > count)
return test_post_create
def build_get_object_update(self):
@@ -102,7 +104,6 @@ def test_post_object_update(self):
self.post_data(),
follow=True)
self.assertTrue(resp.status_code in (302, 200))
- pass
return test_post_object_update
def build_get_object_delete(self):
@@ -110,9 +111,11 @@ def build_get_object_delete(self):
Delete view.
"""
def test_get_object_delete(self):
+ count = self.test_class.objects.count()
resp = self.client.post(self.test_obj.get_delete_url(),
follow=True)
self.assertEqual(resp.status_code, 200)
+ self.assertTrue(self.test_class.objects.count() < count)
return test_get_object_delete
def build_get_object_details(self):
1  cyder/cydns/txt/models.py
View
@@ -8,7 +8,6 @@ class TXT(CydnsRecord):
"""
>>> TXT(label=label, domain=domain, txt_data=txt_data)
"""
-
id = models.AutoField(primary_key=True)
txt_data = models.TextField(help_text="The text data for this record.")
Jacques Uber

Setting fqdn to self.domain.name and at the same time setting label to <something random> and domain to self.domain doesn't make sense.
The fqdn field is calculated (during clean) to equal label + '.' + domain.name. Am I missing something here?

Kevin Ngo

This is formdata, before clean. Fqdn is smartname

Jacques Uber

Ah, okay. That makes more sense.

Please sign in to comment.
Something went wrong with that request. Please try again.