Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
744 additions
and
490 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
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,5 +1,5 @@ | ||
tonicdnscli (0.9-1) unstable; urgency=low | ||
tonicdnscli (0.10-1) unstable; urgency=low | ||
|
||
* Initial release (Closes: #679426) | ||
|
||
-- Kouhei Maeda <mkouhei@palmtb.net> Thu, 13 Sep 2012 15:20:15 +0900 | ||
-- Kouhei Maeda <mkouhei@palmtb.net> Mon, 01 Apr 2013 16:50:28 +0900 |
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
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
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
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
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,2 +1,2 @@ | ||
pep8==1.2 | ||
pep8==1.4 | ||
minimock |
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
File renamed without changes.
8 changes: 3 additions & 5 deletions
8
src/tonicdnscli/tests/test__init__.py → src/tests/test__init__.py
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,18 +1,16 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests of __init__.py | ||
""" | ||
import unittest | ||
import sys | ||
import os.path | ||
sys.path.append(os.path.abspath('src')) | ||
import tonicdnscli | ||
|
||
|
||
class InitTests(unittest.TestCase): | ||
def test_version_defined(self): | ||
actual_version = tonicdnscli.__version__ | ||
self.assertTrue(actual_version) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests of command.py | ||
""" | ||
import unittest | ||
import sys | ||
import os.path | ||
sys.path.append(os.path.abspath('src')) | ||
import tonicdnscli.command as c | ||
import test_vars as v | ||
|
||
|
||
class commandTests(unittest.TestCase): | ||
def setUp(self): | ||
import os.path | ||
self.maxDiff = None | ||
self.domain = 'example.org' | ||
self.cu_records = [{'records': v.dicts1}] | ||
self.r_records = [{'name': 'example.org', | ||
'records': self.cu_records[0].get('records')}] | ||
self.record = ['test3.example.org A 10.10.20.10 3600'] | ||
self.d_cu_record = [{'records': [{'name': 'test3.example.org', | ||
'type': 'A', | ||
'content': '10.10.20.10', | ||
'ttl': 3600}]}] | ||
self.d_r_record = [{'name': self.domain, | ||
'records': [{'name': 'test3.example.org', | ||
'type': 'A', | ||
'content': '10.10.20.10', | ||
'ttl': 3600}]}] | ||
sample0 = os.path.dirname(__file__) + \ | ||
'/../../../examples/example.org.txt' | ||
sample1 = os.path.dirname(__file__) + '/../../examples/example.org.txt' | ||
if os.path.isfile(sample0): | ||
self.sample = sample0 | ||
elif os.path.isfile(sample1): | ||
self.sample = sample1 | ||
|
||
def test_check_infile(self): | ||
self.assertEquals(self.domain, c.check_infile(self.sample)) | ||
|
||
def test_set_json(self): | ||
self.assertEquals(self.cu_records, | ||
c.set_json(self.domain, True, filename=self.sample)) | ||
self.assertEquals(self.r_records, | ||
c.set_json(self.domain, False, filename=self.sample)) | ||
self.assertEquals(self.d_cu_record, | ||
c.set_json(self.domain, True, record=self.record)) | ||
self.assertEquals(self.d_r_record, | ||
c.set_json(self.domain, False, record=self.record)) |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests of connect.py | ||
""" | ||
import unittest | ||
from minimock import mock, Mock, restore | ||
import sys | ||
if sys.version_info > (2, 6) and sys.version_info < (2, 8): | ||
import StringIO as io | ||
elif sys.version_info > (3, 0): | ||
import io as io | ||
if sys.version_info > (2, 6) and sys.version_info < (2, 8): | ||
import urllib2 as urllib | ||
elif sys.version_info > (3, 0): | ||
import urllib.request as urllib | ||
import os.path | ||
sys.path.append(os.path.abspath('src')) | ||
import tonicdnscli.connect as conn | ||
import test_vars as v | ||
|
||
|
||
class connectTests(unittest.TestCase): | ||
def setUp(self): | ||
self.datajson = v.datajson | ||
|
||
self.datadict = v.datadict | ||
|
||
urllib.build_opener = Mock( | ||
'build_opener', | ||
returns=Mock( | ||
'opener', | ||
open=Mock( | ||
'opener.open', | ||
returns=Mock( | ||
'opener.open', | ||
read=Mock( | ||
'opener.open.read', | ||
returns=self.datajson))))) | ||
|
||
self.uri = v.uri | ||
self.token = v.token | ||
self.data = '' | ||
|
||
def tearDown(self): | ||
restore() | ||
|
||
def test_tonicdns_client(self): | ||
dumpout = io.StringIO() | ||
ostdout = sys.stdout | ||
sys.stdout = dumpout | ||
uri = self.uri + '/zone/example.org' | ||
conn.tonicdns_client(uri, | ||
'GET', self.token, self.data) | ||
sys.stdout = ostdout | ||
dumpout.seek(0) | ||
self.assert_(dumpout.getvalue()) | ||
|
||
def test_print_formatted(self): | ||
dumpout = io.StringIO() | ||
ostdout = sys.stdout | ||
sys.stdout = dumpout | ||
conn.print_formatted(self.datadict) | ||
sys.stdout = ostdout | ||
dumpout.seek(0) | ||
self.assert_(dumpout.getvalue()) |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests of converter.py | ||
""" | ||
import unittest | ||
import sys | ||
import os.path | ||
sys.path.append(os.path.abspath('src')) | ||
from tonicdnscli.converter import JSONConverter | ||
import test_vars as v | ||
|
||
|
||
class JSONConvertTests(unittest.TestCase): | ||
|
||
def setUp(self): | ||
sample0 = os.path.dirname(__file__) + \ | ||
'/../../../examples/example.org.txt' | ||
sample1 = os.path.dirname(__file__) + '/../../examples/example.org.txt' | ||
if os.path.isfile(sample0): | ||
self.sample = sample0 | ||
elif os.path.isfile(sample1): | ||
self.sample = sample1 | ||
|
||
def test__init__(self): | ||
o = JSONConverter('example.org') | ||
self.assertEquals('example.org', o.domain) | ||
self.assertEquals(0, o.split_index) | ||
self.assertListEqual([], o.records) | ||
self.assertListEqual([], o.separated_list) | ||
self.assertFalse(o.delta) | ||
|
||
def test_read_records(self): | ||
o = JSONConverter('example.org') | ||
o.read_records(v.str2.splitlines()) | ||
self.assertListEqual(v.dicts1, o.records) | ||
|
||
def test_check_key(self): | ||
o = JSONConverter('example.org') | ||
self.assertEquals("test0.example.org", o.check_key(v.line1, 0)) | ||
self.assertEquals("A", o.check_key(v.line1, 1)) | ||
self.assertEquals("10.10.10.10", o.check_key(v.line1, 2)) | ||
self.assertEquals("86400", o.check_key(v.line1, 3)) | ||
self.assertFalse(o.check_key(v.line1, 4)) | ||
self.assertEquals("0", o.check_key(v.line2, 4)) | ||
self.assertFalse(o.check_key(v.line2, 5)) | ||
self.assertEquals("10.10.11.10", o.check_key(v.line3, 2)) | ||
|
||
def test_generate_records(self): | ||
o = JSONConverter('example.org') | ||
o.generate_records(v.line1) | ||
self.assertListEqual(v.list3, o.records) | ||
o2 = JSONConverter('example.org') | ||
o2.generate_records(v.line2) | ||
self.assertListEqual(v.list4, o2.records) | ||
|
||
def test_generata_data(self): | ||
o1 = JSONConverter('example.org') | ||
o1.generata_data(True) | ||
self.assertListEqual([{'records': []}], o1.dict_records) | ||
o2 = JSONConverter('example.org') | ||
o2.generata_data(False) | ||
self.assertListEqual([{'records': [], 'name': 'example.org'}], | ||
o2.dict_records) | ||
|
||
def test_separate_input_file(self): | ||
import os.path | ||
o = JSONConverter('example.org') | ||
with open(self.sample, 'r') as f: | ||
o.separate_input_file(f) | ||
self.maxDiff = None | ||
self.assertListEqual([v.str1], o.separated_list) | ||
o2 = JSONConverter('example.org') | ||
o2.delta = 3 | ||
with open(self.sample, 'r') as f2: | ||
o2.separate_input_file(f2) | ||
self.assertListEqual(v.str_l, o2.separated_list) | ||
|
||
def test_get_soa(self): | ||
o = JSONConverter('exmaple.org') | ||
self.assertEquals(v.new_soa, | ||
o.get_soa(v.older_cur_soa, v.content)) | ||
self.assertNotEquals(v.new_soa, | ||
o.get_soa(v.today_cur_soa, v.content)) |
Oops, something went wrong.