You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2020/03/01 20:08:18 UTC
[libcloud] branch trunk updated (c39d282 -> bbac86a)
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git.
from c39d282 Merge pull request #1434 from Kami/dns_api_type_annotations
new e2ae2f7 Fix failing tests.
new c67f1a9 Add tests for "_get_numeric_id".
new 6b3f3fd Update Type Enum class so it inherits from str.
new 69a3d60 For now, don't inherit from Type since it causes too many test failures.
new bbac86a Fix annotation position error.
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
libcloud/common/types.py | 2 +-
libcloud/dns/base.py | 10 ++++++++--
libcloud/dns/types.py | 4 ++--
libcloud/test/dns/test_base.py | 26 ++++++++++++++++++++++++++
4 files changed, 37 insertions(+), 5 deletions(-)
[libcloud] 01/05: Fix failing tests.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit e2ae2f74f0bae47033da7444cc78a736fadbf5cd
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Mar 1 20:45:30 2020 +0100
Fix failing tests.
---
libcloud/dns/base.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index 95e2d2a..57611d1 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -559,9 +559,9 @@ class DNSDriver(BaseDriver):
if record.type in [RecordType.MX, RecordType.SRV]:
priority = str(record.extra['priority'])
- parts = [name, ttl, 'IN', record.type, priority, data]
+ parts = [name, ttl, 'IN', str(record.type), priority, data]
else:
- parts = [name, ttl, 'IN', record.type, data]
+ parts = [name, ttl, 'IN', str(record.type), data]
line = '\t'.join(parts)
return line
[libcloud] 05/05: Fix annotation position error.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit bbac86a40f1144d9ca15255009e9d6eada8e51d1
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Mar 1 21:07:31 2020 +0100
Fix annotation position error.
---
libcloud/dns/base.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index 7847f69..06f6425 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -178,13 +178,13 @@ class Record(object):
return self.driver.delete_record(record=self)
def _get_numeric_id(self):
+ # type: () -> Union[int, str]
"""
Return numeric ID for the provided record if the ID is a digit.
This method is used for sorting the values when exporting Zone to a
BIND format.
"""
- # type: () -> Union[int, str]
record_id = self.id
if not record_id:
[libcloud] 04/05: For now,
don't inherit from Type since it causes too many test failures.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 69a3d602cdbbf2e3c38168b966fd3e3f5376fcd2
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Mar 1 21:03:32 2020 +0100
For now, don't inherit from Type since it causes too many test failures.
---
libcloud/dns/types.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcloud/dns/types.py b/libcloud/dns/types.py
index a06bc84..19d0dcb 100644
--- a/libcloud/dns/types.py
+++ b/libcloud/dns/types.py
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from libcloud.common.types import Type
from libcloud.common.types import LibcloudError
__all__ = [
@@ -77,7 +76,8 @@ OLD_CONSTANT_TO_NEW_MAPPING = {
}
-class RecordType(Type):
+class RecordType(object):
+ # TODO: Fix all the affected code and tests and use base Type class here
"""
DNS record type.
"""
[libcloud] 03/05: Update Type Enum class so it inherits from str.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 6b3f3fdb2c57537069db38ef72c94c323dea043d
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Mar 1 20:57:36 2020 +0100
Update Type Enum class so it inherits from str.
This way all the enum types are also JSON serializable.
---
libcloud/common/types.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcloud/common/types.py b/libcloud/common/types.py
index e73b295..7b0ad4f 100644
--- a/libcloud/common/types.py
+++ b/libcloud/common/types.py
@@ -38,7 +38,7 @@ __all__ = [
]
-class Type(Enum):
+class Type(str, Enum):
@classmethod
def tostring(cls, value):
# type: (Union[Enum, str]) -> str
[libcloud] 02/05: Add tests for "_get_numeric_id".
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit c67f1a97babbec3e67bed3df17a2ece45bff0d84
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Mar 1 20:48:46 2020 +0100
Add tests for "_get_numeric_id".
---
libcloud/dns/base.py | 6 ++++++
libcloud/test/dns/test_base.py | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index 57611d1..7847f69 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -178,6 +178,12 @@ class Record(object):
return self.driver.delete_record(record=self)
def _get_numeric_id(self):
+ """
+ Return numeric ID for the provided record if the ID is a digit.
+
+ This method is used for sorting the values when exporting Zone to a
+ BIND format.
+ """
# type: () -> Union[int, str]
record_id = self.id
diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index 9541509..3472d5e 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -105,6 +105,32 @@ class BaseTestCase(unittest.TestCase):
assertRegex(self, lines[10], r'example.com\.\s+900\s+IN\s+MX\s+10\s+mx.example.com')
assertRegex(self, lines[11], r'example.com\.\s+900\s+IN\s+SRV\s+20\s+10 3333 example.com')
+ def test_get_numeric_id(self):
+ values = MOCK_RECORDS_VALUES[0].copy()
+ values['driver'] = self.driver
+ values['zone'] = None
+ record = Record(**values)
+
+ record.id = 'abcd'
+ result = record._get_numeric_id()
+ self.assertEqual(result, 'abcd')
+
+ record.id = '1'
+ result = record._get_numeric_id()
+ self.assertEqual(result, 1)
+
+ record.id = '12345'
+ result = record._get_numeric_id()
+ self.assertEqual(result, 12345)
+
+ record.id = ''
+ result = record._get_numeric_id()
+ self.assertEqual(result, '')
+
+ record.id = None
+ result = record._get_numeric_id()
+ self.assertEqual(result, '')
+
if __name__ == '__main__':
sys.exit(unittest.main())