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

re-add testing

parent 144b6fad
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
version: '3.7'

services:
  package:
    build: .
    volumes:
      - ./src/:/tmp/src
    environment:
      - DATABASE_HOST=postgres
      - DATABASE_TIMEOUT=60
      - LOGLEVEL=debug
    command: ["sh", "-c", "python3 /test/test.py"]
    depends_on:
      - postgres

  postgres:
    image: postgres
    environment: 
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_DB=postgres
    volumes:
      - ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
      - ./sql/fill_tables.sql:/docker-entrypoint-initdb.d/fill_tables.sql

# find what tables already exist in an empty database or initialize a table
# then use that for testing purposes

test/test.py

0 → 100644
+23 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Unit test common functionality"""
import unittest
from common.database import Database
from common.mixins.postgres import PostgresMixin

class DBPG(Database, PostgresMixin):
    pass

class PostgresTestCase(unittest.TestCase):
    def setUp(self) -> None:
        return super().setUp()
    
    def test_open(self):
        with DBPG() as db:
            print(db.query("SELECT * FROM test_table"))


if __name__ =="__main__":
    unittest.main(verbosity=2)