Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

Commit

Permalink
Testcase for AvivoreConfig added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rc0r committed Jan 4, 2015
1 parent 3f72503 commit 588e907
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
before_install:
Expand Down
9 changes: 6 additions & 3 deletions AvivoreXT/AvivoreConfig.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# -*- coding: utf8 -*-
from AvivoreXT import Helper
import ConfigParser
from AvivoreXT import Compat, Helper
import os
import sqlite3 as lite

if Compat.is_python3():
from configparser import ConfigParser
else:
from ConfigParser import ConfigParser

class AvivoreConfig:
def __init__(self, config_type, config_filename):
self.config_type = config_type
self.config_filename = config_filename
self.config = ConfigParser.ConfigParser()
self.config = ConfigParser()
self.twitter_search_types = []
self.twitter_search_terms = []
self.twitter_track_keywords = None
Expand Down
6 changes: 6 additions & 0 deletions AvivoreXT/Compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf8 -*-
import sys


def is_python3():
return sys.version_info[0] == 3
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
author='rc0r',
author_email='hlt99@blinkenshell.org',
url='https://github.com/rc0r/AvivoreXT',
install_requires = dependencies,
install_requires=dependencies,
scripts=scripts,
packages=find_packages(),
test_suite='tests',
packages=find_packages(exclude=['test']),
test_suite='test',
)
File renamed without changes.
73 changes: 73 additions & 0 deletions test/test_AvivoreConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-

import unittest
#from test import test_support
from AvivoreXT import Compat, AvivoreConfig

if Compat.is_python3():
from configparser import ConfigParser
else:
from ConfigParser import ConfigParser


class AvivoreConfigTestCase(unittest.TestCase):
# def setUp(self):
# # code to execute in preparation for tests
# pass
#
# def tearDown(self):
# # code to execute to clean up after tests
# pass
def test_init(self):
config_files = [
'testdata/test.conf',
'testdata/test.db',
'invalidpath/invalidfile',
]

for i in range(0, 10, 1):
for j in range(0, len(config_files), 1):
avivore_conf_inst = AvivoreConfig.AvivoreConfig(i, config_files[j])
self.assertTrue(avivore_conf_inst.config_type == i)
self.assertTrue(avivore_conf_inst.config_filename == config_files[j])
self.assertTrue(isinstance(avivore_conf_inst.config, ConfigParser))
self.assertTrue(avivore_conf_inst.twitter_search_types == [])
self.assertTrue(avivore_conf_inst.twitter_search_terms == [])
self.assertTrue(avivore_conf_inst.twitter_track_keywords is None)
self.assertTrue(avivore_conf_inst.twitter_consumer_key is None)
self.assertTrue(avivore_conf_inst.twitter_consumer_secret is None)
self.assertTrue(avivore_conf_inst.twitter_search_interval == 30)
self.assertTrue(avivore_conf_inst.credentials_file is None)
self.assertTrue(avivore_conf_inst.database_path is None)

def test_read_config(self):
pass

def test_init_config_database(self):
pass

def test_init_database(self):
pass


def test_main():
#test_support.run_unittest(AvivoreConfigTestCase)
#suite = unittest.defaultTestLoader.loadTestsFromTestCase(AvivoreConfigTestCase)
#unittest.TextTestRunner().run(suite)
#unittest.main()

suite = unittest.TestSuite()
loader = unittest.TestLoader()
tcl = loader.loadTestsFromTestCase

testClasses = [
'AvivoreConfigTestCase'
]

for c in testClasses:
suite.addTest(tcl(c))

unittest.TextTestRunner(verbosity=2).run(suite)

if __name__ == '__main__':
test_main()
23 changes: 20 additions & 3 deletions tests/test_Helper.py → test/test_Helper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-

import unittest
from test import test_support
#from test import test_support
from array import array
import AvivoreXT
from AvivoreXT import Helper


Expand Down Expand Up @@ -71,7 +70,25 @@ def test_output(self):


def test_main():
test_support.run_unittest(HelperTestCase)
#test_support.run_unittest(HelperTestCase)
#unittest.main()

#suite = unittest.defaultTestLoader.loadTestsFromTestCase(HelperTestCase)
#unittest.TextTestRunner().run(suite)

suite = unittest.TestSuite()
loader = unittest.TestLoader()
tcl = loader.loadTestsFromTestCase

testClasses = [
'HelperTestCase'
]

for c in testClasses:
suite.addTest(tcl(c))

unittest.TextTestRunner(verbosity=2).run(suite)


if __name__ == '__main__':
test_main()

0 comments on commit 588e907

Please sign in to comment.