Browse Source

added HostingService

Fabian Peter Hammerle 7 years ago
parent
commit
d8121ae42a
3 changed files with 57 additions and 3 deletions
  1. 19 0
      finoex/__init__.py
  2. 3 3
      setup.py
  3. 35 0
      tests/test_yaml.py

+ 19 - 0
finoex/__init__.py

@@ -383,6 +383,25 @@ class Service(Item):
             self.state = state
 
 
+class HostingService(Service):
+
+    yaml_tag = u'!hosting-service'
+
+    def __init__(self,
+                 ip_addresses=None,
+                 operating_system=None,
+                 **kwargs
+                 ):
+        super(HostingService, self).__init__(**kwargs)
+        if ip_addresses:
+            assert isinstance(ip_addresses, list)
+            assert all([isinstance(a, str) for a in ip_addresses])
+            self.ip_addresses = ip_addresses
+        if operating_system:
+            assert isinstance(operating_system, str)
+            self.operating_system = operating_system
+
+
 class Transportation(Item):
 
     yaml_tag = u'!transportation'

+ 3 - 3
setup.py

@@ -4,13 +4,13 @@ import glob
 
 setup(
     name = 'finoex',
-    version = '0.4.0',
+    version = '0.5.0',
     # description = '',
     author = 'Fabian Peter Hammerle',
     author_email = 'fabian.hammerle@gmail.com',
     url = 'https://git.hammerle.me/fphammerle/finoex',
-    download_url = 'https://git.hammerle.me/fphammerle/finoex/archive/0.3.0.tar.gz',
-    # keywords = [],
+    download_url = 'https://git.hammerle.me/fphammerle/finoex/archive/0.5.0.tar.gz',
+    keywords = ['finances'],
     # classifiers = [],
     packages = ['finoex'],
     # scripts = glob.glob('scripts/*'),

+ 35 - 0
tests/test_yaml.py

@@ -44,6 +44,17 @@ def get_service_a():
         state = 'success',
         )
 
+def get_hosting_service():
+    return finoex.HostingService(
+        duration = ioex.datetimeex.Duration(years = 2),
+        ip_addresses = ['127.0.0.1', '::1'],
+        location = 'vienna',
+        name = u'virtual server',
+        operating_system = 'debian 8',
+        price_brutto = finoex.Sum(1.0, u'EUR'),
+        state = 'running',
+        )
+
 def get_service_b():
     return finoex.Service(
         name = u'service',
@@ -264,6 +275,18 @@ period: !period
   end: null
   start: 2017-04-02 10:23:00
 price_brutto: !sum '1.0 EUR'
+"""],
+    [get_hosting_service(), u"""!hosting-service
+duration: !duration
+  years: 2
+ip_addresses:
+- 127.0.0.1
+- ::1
+location: vienna
+name: virtual server
+operating_system: debian 8
+price_brutto: !sum '1.0 EUR'
+state: running
 """],
     [get_pledge(), u"""!pledge
 campaign: !campaign
@@ -420,6 +443,18 @@ name: service
 period: !period
   start: 2017-04-02 10:23:00
 price_brutto: !sum '1.0 EUR'
+"""],
+    [get_hosting_service(), u"""!hosting-service
+duration: !duration
+  years: 2
+ip_addresses:
+- 127.0.0.1
+- ::1
+location: vienna
+name: virtual server
+operating_system: debian 8
+price_brutto: !sum '1.0 EUR'
+state: running
 """],
     [get_pledge(), u"""!pledge
 campaign: !campaign