Commit ea7ec202 authored by Huihui, Jonathan's avatar Huihui, Jonathan
Browse files

update test for db conn

parent 0c3c2b2c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
FROM python:3.9-slim

RUN apt-get -yqq update && apt-get -yqq upgrade && \
      apt-get -yqq install vim 
      apt-get -yqq install vim && apt-get -yqq install postgresql-client

COPY src/ tmp/src

@@ -11,4 +11,5 @@ RUN set -eux && pip install --upgrade pip && \

COPY ./test/test.py /test/test.py


CMD ['sh', 'tail', '-f', '/dev/null']
+5 −1
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ services:
      - ./test/:/test/
    environment:
      - DATABASE_HOST=postgres
      - DATABASE_DB=postgres
      - DATABASE_PORT=5432
      - DATABASE_USER=postgres
      - DATABASE_PW=postgres
      - DATABASE_TIMEOUT=60
      - DATABASE_LOG_FILE=test.log
      - DATABASE_LOG_MODE=w
@@ -17,7 +21,7 @@ services:
      - postgres

  postgres:
    image: postgres
    image: postgres:14.0
    environment: 
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_USER=postgres
+4 −0
Original line number Diff line number Diff line
@@ -7,6 +7,10 @@ services:
      - ./src/:/tmp/src
    environment:
      - DATABASE_HOST=postgres
      - DATABASE_DB=postgres
      - DATABASE_PORT=5432
      - DATABASE_USER=postgres
      - DATABASE_PW=postgres
      - DATABASE_TIMEOUT=60
    command:
      - 'tail'
+7 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
"""Unit test common functionality."""
import unittest
import os
import subprocess
from common.database import Database
from common.mixins.postgres import PostgresMixin
from common.logz import create_logger
@@ -24,6 +25,12 @@ class PostgresTestCase(unittest.TestCase):
            print(data_base.query("SELECT * FROM test_table"))


class DBConnTestCase(unittest.TestCase):
    def test_connection(self):
        status_run = subprocess.call('test-db-conn')
        print(status_run)
        self.assertTrue(status_run==0)

class LogzTestCase(unittest.TestCase):
    """
    LogzTestCase: