From dd5f700e6e2f9969d7c37d3cef3c3624adffe3f5 Mon Sep 17 00:00:00 2001
From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Date: Tue, 19 Oct 2010 17:02:50 +0300
Subject: [PATCH] tentatively package unittests in rpm sfa-tests, for the
 nightlies

---
 .gitignore       |  4 +++-
 Makefile         | 21 ++++++++++++++++-----
 sfa.spec         | 13 ++++++++++++-
 tests/testXrn.py | 20 ++++++++++++++++----
 4 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index 302bd964..1b02ac74 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+.gitignore
 build/*
-*.pyc
\ No newline at end of file
+*.pyc
+TAGS
diff --git a/Makefile b/Makefile
index eaa6b3c7..2446adce 100644
--- a/Makefile
+++ b/Makefile
@@ -5,15 +5,15 @@
 DESTDIR="/"
 
 ##########
-all: python wsdl
+all: python wsdl 
 
-install: python-install wsdl-install xmlbuilder-install 
+install: python-install wsdl-install xmlbuilder-install tests-install
 
-clean: python-clean wsdl-clean
+clean: python-clean wsdl-clean 
 
-uninstall: python-uninstall
+uninstall: python-uninstall tests-uninstall
 
-.PHONY: all install clean 
+.PHONY: all install clean uninstall
 
 ##########
 python: 
@@ -43,6 +43,17 @@ wsdl-clean:
 
 .PHONY: wsdl wsdl-install wsdl-clean
 
+
+##########
+tests-install:
+	mkdir -p $(DESTDIR)/usr/share/sfa/tests
+	install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
+
+tests-uninstall:
+	rm -rf $(DESTDIR)/usr/share/sfa/tests
+
+.PHONY: tests-install tests-uninstall
+
 ########## refreshing methods package metafile
 # Metafiles - manage Legacy/ and Accessors by hand
 init := sfa/methods/__init__.py 
diff --git a/sfa.spec b/sfa.spec
index c11fa238..b99b8ed5 100644
--- a/sfa.spec
+++ b/sfa.spec
@@ -52,7 +52,7 @@ Requires: python-dateutil
 #%endif
 
 %package cm
-Summary: the SFA wrapper around MyPLC's NodeManager
+Summary: the SFA wrapper around MyPLC NodeManager
 Group: Applications/System
 Requires: sfa
 Requires: pyOpenSSL >= 0.6
@@ -76,6 +76,11 @@ Summary: sfatables policy tool for SFA
 Group: Applications/System
 Requires: sfa
 
+%Package tests
+Summary: unit tests suite for SFA
+Group: Applications/System
+Requires: sfa
+
 %description
 This package provides the python libraries that the SFA implementation requires
 
@@ -96,6 +101,9 @@ sfatables is a tool for defining access and admission control policies
 in an SFA network, in much the same way as iptables is for ip
 networks. This is the command line interface to manage sfatables
 
+%description tests
+Provides some binary unit tests in /usr/share/sfa/tests
+
 %prep
 %setup -q
 
@@ -147,6 +155,9 @@ rm -rf $RPM_BUILD_ROOT
 %files sfatables
 %{_bindir}/sfatables
 
+%files tests
+%{_datadir}/sfa/tests
+
 ### sfa-plc installs the 'sfa' service
 %post plc
 chkconfig --add sfa
diff --git a/tests/testXrn.py b/tests/testXrn.py
index 9725652d..582ebe62 100755
--- a/tests/testXrn.py
+++ b/tests/testXrn.py
@@ -69,7 +69,19 @@ class TestXrn(unittest.TestCase):
     def test_hrn010(self):
         self.__hrn("plc.vini.site", 'authority',
                    "urn:publicid:IDN+plc:vini:site+authority+sa" )
-        
+
+    # this one is a bit off limits but it's used in some places
+    # like .e.g when running sfi.py resources
+    def test_void(self):
+        void=Xrn(xrn='',type=None)
+        expected='urn:publicid:IDN++'
+        self.assertEqual(void.get_hrn(),'')
+        self.assertEqual(void.get_type(),None)
+        self.assertEqual(void.get_urn(),expected)
+        loop=Xrn(urn=expected)
+        self.assertEqual(loop.get_hrn(),'')
+        # xxx - this is not quite right as the first object has type None
+        self.assertEqual(loop.get_type(),'')        
 
     
     def test_host001 (self):
@@ -94,14 +106,14 @@ class TestXrn(unittest.TestCase):
 
     def test_login_base_001 (self):
         xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
-        self.assertEqual(xrn.login_base(),'inria')
+        self.assertEqual(xrn.pl_login_base(),'inria')
 
     def test_slicename_001 (self):
         xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
-        self.assertEqual(xrn.slicename(),'inria_omftest')
+        self.assertEqual(xrn.pl_slicename(),'inria_omftest')
 
     def test_authname_001 (self):
         xrn=PlXrn(hrn='ple.inria.omftest',type='slice')
-        self.assertEqual(xrn.authname(),'inria')
+        self.assertEqual(xrn.pl_authname(),'inria')
 
 
-- 
2.47.0