Skip to content
Permalink
Browse files

Update unittest

  • Loading branch information...
jssuzanne
jssuzanne committed Sep 14, 2018
1 parent 51b0ae6 commit b2c1a086309d4e6717f924826ce60fc7177a5a91
Showing with 22 additions and 0 deletions.
  1. +2 −0 .coveragerc
  2. +20 −0 anyblok/tests/test_registry.py
@@ -14,3 +14,5 @@ omit =
exclude_lines =
# unexecuting logger
logger\.
# exclude all import error of unloaded module
except ImportError:
@@ -11,8 +11,16 @@
from anyblok.config import Configuration
from anyblok.blok import BlokManager, Blok
from anyblok.column import Integer
from anyblok import start
from threading import Thread
from logging import ERROR
import sys

try:
# python 3.4+ should use builtin unittest.mock not mock package
from unittest.mock import patch
except ImportError:
from mock import patch


class Test:
@@ -118,6 +126,18 @@ def test_add_in_registry_1(self):
registry.add_in_registry('Declarations.Test.Test.Test', TestTestTest)
self.check_added_in_regisry(registry)

def test_start_function(self):
BlokManager.unload()
db_name = Configuration.get('db_name') or 'test_anyblok'
db_driver_name = Configuration.get('db_driver_name') or 'postgresql'

testargs = ['default', '--db-name', db_name, '--db-driver-name',
db_driver_name]
with patch.object(sys, 'argv', testargs):
registry = start('default')

self.assertIsNotNone(registry)

def test_add_in_registry_2(self):
registry = self.init_registry(None)
registry.add_in_registry('Declarations.Test', Test)

0 comments on commit b2c1a08

Please sign in to comment.
You can’t perform that action at this time.