Implemented initial version of unittests for rsync_url

Change-Id: I3f94529a1ce774dcf94c9a44e573abd633fdd841
diff --git a/test_rsync_url.py b/test_rsync_url.py
new file mode 100644
index 0000000..5166b6c
--- /dev/null
+++ b/test_rsync_url.py
@@ -0,0 +1,50 @@
+#-*- coding: utf-8 -*-
+
+import rsync_url
+import unittest
+import yaml
+
+
+class TestRsyncUrl(unittest.TestCase):
+
+    def exact_match_num(self, remote, expected_result):
+        url = rsync_url.RsyncUrl(remote)
+        matching_regexps = url._get_all_matching_regexps()
+        self.assertEqual(len(matching_regexps), expected_result)
+
+    def classed(self, remote, expected_result):
+        url = rsync_url.RsyncUrl(remote)
+        self.assertEqual(url.url_type, expected_result)
+
+    def parsed(self, remote, expected_result):
+        url = rsync_url.RsyncUrl(remote)
+        self.assertEqual(
+            [url.user, url.host, url.port, url.path],
+            expected_result
+        )
+
+
+testdata = yaml.load(open('test_rsync_url.yaml'))
+
+index = 1
+for remote, tests in testdata.items():
+
+    for test, expected in tests.items():
+
+        print index, test, expected
+
+        def test_function(self, test=test,
+                          remote=remote, expected_result=expected):
+            getattr(self, test)(remote, expected_result)
+
+        test_function.__name__ = \
+            'test_{}_{}_{}'.format(index, tests['classed'], test)
+        test_function.__doc__ = test_function.__name__
+        setattr(TestRsyncUrl, test_function.__name__, test_function)
+        del test_function
+
+    index += 1
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/test_rsync_url.yaml b/test_rsync_url.yaml
new file mode 100644
index 0000000..d784da3
--- /dev/null
+++ b/test_rsync_url.yaml
@@ -0,0 +1,159 @@
+# description format:
+# url:
+#   test_function_name_1: expected_result
+#   test_function_name_2: [expected, results]
+#   test_function_name_3:
+#     - expected
+#     - results
+'ubuntu@172.18.66.89:~':
+  exact_match_num: 1
+  classed: 'ssh'
+  parsed:
+    - 'ubuntu'
+    - '172.18.66.89'
+    - null
+    - '~'
+'johnivanov@172.18.66.89:/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'ssh'
+  parsed:
+    - 'johnivanov'
+    - '172.18.66.89'
+    - null
+    - '/mirror-sync/otlichniy/reg/exp'
+'172.18.66.89:/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'ssh'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/mirror-sync/otlichniy/reg/exp'
+'172.18.66.89:/':
+  exact_match_num: 1
+  classed: 'ssh'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'172.18.66.89:':
+  exact_match_num: 1
+  classed: 'ssh'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'johnivanov@172.18.66.89::/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'rsync1'
+  parsed:
+    - 'johnivanov'
+    - '172.18.66.89'
+    - null
+    - '/mirror-sync/otlichniy/reg/exp'
+'172.18.66.89::/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'rsync1'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/mirror-sync/otlichniy/reg/exp'
+'172.18.66.89::/':
+  exact_match_num: 1
+  classed: 'rsync1'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'172.18.66.89::':
+  exact_match_num: 1
+  classed: 'rsync1'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'rsync://mirror-sync@172.18.66.89:7327/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'rsync2'
+  parsed:
+    - 'mirror-sync'
+    - '172.18.66.89'
+    - 7327
+    - '/otlichniy/reg/exp'
+'rsync://172.18.66.89:7327/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'rsync2'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - 7327
+    - '/mirror-sync/otlichniy/reg/exp'
+'rsync://172.18.66.89/mirror-sync/otlichniy/reg/exp':
+  exact_match_num: 1
+  classed: 'rsync2'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/mirror-sync/otlichniy/reg/exp'
+'rsync://172.18.66.89/':
+  exact_match_num: 1
+  classed: 'rsync2'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'rsync://172.18.66.89':
+  exact_match_num: 1
+  classed: 'rsync2'
+  parsed:
+    - null
+    - '172.18.66.89'
+    - null
+    - '/'
+'/':
+  exact_match_num: 1
+  classed: 'path'
+  parsed:
+    - null
+    - null
+    - null
+    - '/'
+'dir':
+  exact_match_num: 1
+  classed: 'path'
+  parsed:
+    - null
+    - null
+    - null
+    - 'dir'
+'/dir':
+  exact_match_num: 1
+  classed: 'path'
+  parsed:
+    - null
+    - null
+    - null
+    - '/dir'
+'/dir/subdir/':
+  exact_match_num: 1
+  classed: 'path'
+  parsed:
+    - null
+    - null
+    - null
+    - '/dir/subdir/'
+'':
+  exact_match_num: 0
+  classed: null
+  parsed:
+    - null
+    - null
+    - null
+    - null