Skip to content

Commit

Permalink
Add initial CLI integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Jan 22, 2024
1 parent bd94a25 commit c21f5b3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tests.mongo_mock import MongoMock
from tests.opensearch_mock import OpenSearchMock
from tests.opensearch import OpenSearch
from tests.cli import CLI

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
Expand Down
41 changes: 41 additions & 0 deletions tests/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import unittest
import logging
from time import sleep


class CLI(unittest.TestCase):
"""
Testing OpenSearch database CLI integration.
"""

@classmethod
def setUpClass(cls):
"""
Set up OpenSearch database connection and login with CLI.
"""
if os.getenv("GITHUB_ACTIONS") != "true":
raise unittest.SkipTest("Only runs via GitHub Actions")
cls.security_enabled = os.getenv("security_enabled") == "true"
cls.port = int(os.environ["port"])
cls.host = "localhost"

logging.basicConfig(level=logging.INFO)

url = f"opensearch://admin:admin@{cls.host}:{cls.port}"
if not cls.security_enabled:
url += " --disable_ssl"
try:
os.system(f"abcd login {url}")
except (ConnectionError, ConnectionResetError):
sleep(10)
os.system(f"abcd login {url}")

def test_summary(self):
"""
Test summary output of stored data.
"""
class_path = os.path.normpath(os.path.abspath(__file__))
data_file = os.path.dirname(class_path) + "/data/example.xyz"
os.system(f"abcd upload {data_file}")
os.system("abcd summary")
4 changes: 4 additions & 0 deletions tests/data/example.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2
Properties=species:S:1:pos:R:3 s="sadf" _vtk_test="t _ e s t" pbc="F F F"
Si 0.00000000 1.00000000 2.00000000
Si 4.00000000 5.00000000 6.00000000

0 comments on commit c21f5b3

Please sign in to comment.