You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sdap.apache.org by GitBox <gi...@apache.org> on 2020/07/21 16:31:38 UTC

[GitHub] [incubator-sdap-ingester] tloubrieu-jpl opened a new pull request #6: add unit tests and support for git username/token (SDAP-247)

tloubrieu-jpl opened a new pull request #6:
URL: https://github.com/apache/incubator-sdap-ingester/pull/6


   add login for kopf operator (helps for integration in k8s different versions)
   add unit tests for config_source
   support username/token
   add unit test for K8sConfigMap


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-sdap-ingester] eamonford merged pull request #6: add unit tests and support for git username/token (SDAP-247)

Posted by GitBox <gi...@apache.org>.
eamonford merged pull request #6:
URL: https://github.com/apache/incubator-sdap-ingester/pull/6


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-sdap-ingester] eamonford commented on a change in pull request #6: add unit tests and support for git username/token (SDAP-247)

Posted by GitBox <gi...@apache.org>.
eamonford commented on a change in pull request #6:
URL: https://github.com/apache/incubator-sdap-ingester/pull/6#discussion_r458995312



##########
File path: config_operator/README.md
##########
@@ -25,7 +25,7 @@ The component runs as a kubernetes operator (see containerization section)
 To publish the docker image on dockerhub do (step necessary for kubernetes deployment):
 
     docker login
-    docker push tloubrieu/sdap-ingest-manager:latest
+    docker push tloubrieu/config-operator:latest

Review comment:
       can you change this to `nexusjpl/config-operator:latest`?

##########
File path: config_operator/tests/config_source/test_LocalDirConfig.py
##########
@@ -0,0 +1,70 @@
+import asyncio
+import unittest
+from unittest.mock import Mock
+from unittest.mock import patch
+import os
+import time
+from datetime import datetime
+from config_operator.config_source import LocalDirConfig
+from config_operator.config_source.exceptions import UnreadableFileException
+
+
+
+class MyTestCase(unittest.TestCase):
+    def test_get_files(self):
+        local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirTest")
+        local_dir_config = LocalDirConfig(local_dir)
+        files = local_dir_config.get_files()
+        self.assertEqual(len(files), 1)
+        self.assertEqual(files[0], 'collections.yml')
+
+    def test_get_good_file_content(self):
+        local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirTest")
+        local_dir_config = LocalDirConfig(local_dir)
+        files = local_dir_config.get_files()
+        content = local_dir_config.get_file_content(files[0])
+        self.assertEqual(content.strip(), 'test: 1')
+
+    def test_get_bad_file_content(self):
+        unreadable_file = False
+        try:
+            local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirBadTest")
+            local_dir_config = LocalDirConfig(local_dir)
+            files = local_dir_config.get_files()
+            content = local_dir_config.get_file_content(files[0])
+        except UnreadableFileException as e:
+            unreadable_file = True
+
+        finally:
+            self.assertTrue(unreadable_file)
+
+    def test_when_udated(self):
+
+        callback = Mock()
+        local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirTest")
+
+        local_dir_config = LocalDirConfig(local_dir, update_every_seconds=0.25, update_date_fun=lambda x: datetime.now().timestamp())
+
+        asyncio.run(local_dir_config.when_updated(callback))
+
+        time.sleep(2)
+
+        assert callback.called
+
+    def test_when_not_udated(self):

Review comment:
       typo here too

##########
File path: config_operator/tests/config_source/test_LocalDirConfig.py
##########
@@ -0,0 +1,70 @@
+import asyncio
+import unittest
+from unittest.mock import Mock
+from unittest.mock import patch
+import os
+import time
+from datetime import datetime
+from config_operator.config_source import LocalDirConfig
+from config_operator.config_source.exceptions import UnreadableFileException
+
+
+
+class MyTestCase(unittest.TestCase):
+    def test_get_files(self):
+        local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirTest")
+        local_dir_config = LocalDirConfig(local_dir)
+        files = local_dir_config.get_files()
+        self.assertEqual(len(files), 1)
+        self.assertEqual(files[0], 'collections.yml')
+
+    def test_get_good_file_content(self):
+        local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirTest")
+        local_dir_config = LocalDirConfig(local_dir)
+        files = local_dir_config.get_files()
+        content = local_dir_config.get_file_content(files[0])
+        self.assertEqual(content.strip(), 'test: 1')
+
+    def test_get_bad_file_content(self):
+        unreadable_file = False
+        try:
+            local_dir = os.path.join(os.path.dirname(__file__), "../resources/localDirBadTest")
+            local_dir_config = LocalDirConfig(local_dir)
+            files = local_dir_config.get_files()
+            content = local_dir_config.get_file_content(files[0])
+        except UnreadableFileException as e:
+            unreadable_file = True
+
+        finally:
+            self.assertTrue(unreadable_file)
+
+    def test_when_udated(self):

Review comment:
       typo, should be `test_when_updated`

##########
File path: config_operator/tests/config_source/test_LocalDirConfig.py
##########
@@ -0,0 +1,70 @@
+import asyncio
+import unittest
+from unittest.mock import Mock
+from unittest.mock import patch
+import os
+import time
+from datetime import datetime
+from config_operator.config_source import LocalDirConfig
+from config_operator.config_source.exceptions import UnreadableFileException
+
+
+
+class MyTestCase(unittest.TestCase):

Review comment:
       Maybe make this a bit more descriptive?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org