Skip to content

Commit

Permalink
Integration tests on remote
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturOle committed Aug 29, 2024
1 parent 2411bf4 commit beeeca7
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
run: docker compose build

- name: Run tests
run: docker compose run test
run: docker compose up --abort-on-container-exit
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ services:
- "7687:7687"
environment:
- NEO4J_AUTH=neo4j/StrongPsPsP5
- SSL_CERT_DIR=/etc/ssl/certs

test:
build: .
build:
context: .
dockerfile: dockerfile
depends_on:
- database
links:
- database
container_name: ragger
command: bash -c "python3 -m pytest || exit 1"
environment:
- SSL_CERT_DIR=/etc/ssl/certs
command: >
bash -c "python3 -m pytest || exit 1"
&& docker-compose down
4 changes: 3 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ ENV DEBIAN_FRONTEND=noninteractive
CMD ["bash"]

RUN apt-get update
RUN apt-get install -y python3 python3-pip git
RUN apt-get install -y python3 python3-pip git ca-certificates lsb-release ubuntu-keyring software-properties-common
RUN update-ca-certificates --fresh
RUN export SSL_CERT_DIR=/etc/ssl/certs
RUN pip3 install torch --index-url https://download.pytorch.org/whl/cpu
RUN apt install -y tesseract-ocr
RUN apt install -y libtesseract-dev
Expand Down
14 changes: 14 additions & 0 deletions dockerfile_neo4j
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install wget curl nano software-properties-common dirmngr apt-transport-https gnupg gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y

RUN curl -fsSL https://debian.neo4j.com/neotechnology.gpg.key | gpg --dearmor -o /usr/share/keyrings/neo4j.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/neo4j.gpg] https://debian.neo4j.com stable latest" | tee -a /etc/apt/sources.list.d/neo4j.list
RUN apt-get install -y neo4j
RUN systemctl enable neo4j.service
RUN systemctl start neo4j.service
ENV NEO4J_AUTH=neo4j/StrongPsPsP5
EXPOSE 7687
4 changes: 2 additions & 2 deletions ragger/data_manager/communication/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def add_literature(self, session, literature: Literature):
def _add_literature(self, tx, literature: Literature):
try:
tx.run(
"MERGE (a:Literature {filename: $filename, text: $text, text_position: $text_position, page_number: $page_number})",
"CREATE (a:Literature {filename: $filename, text: $text, text_position: $text_position, page_number: $page_number})",
filename=literature.filename,
text=literature.text,
text_position=literature.text_position,
Expand Down Expand Up @@ -109,7 +109,7 @@ def _delete_literature(self, tx, filename):


if __name__ == "__main__":
communicator = Communicator("neo4j://localhost:7687", "neo4j", "StrongPsPsP5")
communicator = Communicator("neo4j+ssc://localhost:7687", "neo4j", "StrongPsPsP5")
print("Communicator created.")
literature = Literature("test", "This is a test text.", 0, 0)
communicator.add_literature(literature)
Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ PyMuPDF
langchain
langchain-text-splitters
pytextrank
transformers
transformers
neo4j
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
-r base.txt
pytest >= 8.3.2

11 changes: 5 additions & 6 deletions test/data_manager_test/communication_test/communicator_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest

from data_manager.communication import Communicator
from data_manager.data_classes import Literature
from ragger.data_manager.communication import Communicator
from ragger.data_manager.data_classes import Literature

# These test are mix of unit and integration tests on purpouse.
# Mocking these tests would not make sense


class TestCommunicatorConnection:
Expand All @@ -18,8 +21,6 @@ def test_communicator_creation(test):


class TestCommunicatorTransactions:
@pytest.mark.dependency(
depends=["TestCommunicatorConnection::test_communicator_creation"])
def setup_test(test):
test.uri = "neo4j://localhost:7687"
test.user = "neo4j"
Expand All @@ -32,8 +33,6 @@ def setup_test(test):
page_number=0
)

@pytest.mark.dependency(
depends=["TestCommunicatorConnection::test_communicator_creation"])
def test_add_literature(test):
test.setup_test()
test.communicator.add_literature(test.literature)
Expand Down

0 comments on commit beeeca7

Please sign in to comment.