Skip to content

Commit

Permalink
test cases separated into individual functions for easier testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Simkovic committed Feb 18, 2017
1 parent 92f1a17 commit 189fb48
Show file tree
Hide file tree
Showing 27 changed files with 478 additions and 742 deletions.
142 changes: 52 additions & 90 deletions conkit/core/tests/test_Contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@

class Test(unittest.TestCase):

def test_distance_bound(self):
# ======================================================
# Test Case 1
def test_distance_bound_1(self):
contact = Contact(1, 2, 1.0)
contact.distance_bound = (0, 8)
self.assertEqual((0, 8), contact.distance_bound)
# ======================================================
# Test Case 2

def test_distance_bound_2(self):
contact = Contact(1, 2, 1.0)
contact.distance_bound = (0, 8)
self.assertEqual((0, 8), contact.distance_bound)
self.assertTrue(isinstance(contact.distance_bound, tuple))
# ======================================================
# Test Case 3

def test_distance_bound_3(self):
contact = Contact(1, 2, 1.0)
try:
contact.distance_bound = (1, 100)
Expand All @@ -34,44 +32,38 @@ def test_distance_bound(self):
with self.assertRaises(TypeError):
contact.distance_bound = 'test'

def test_is_false_positive(self):
# ======================================================
# Test Case 1
def test_is_false_positive_1(self):
contact = Contact(1, 2, 1.0)
contact.define_false_positive()
self.assertTrue(contact.is_false_positive)
self.assertFalse(contact.is_true_positive)

def test_is_true_positive(self):
# ======================================================
# Test Case 1
def test_is_true_positive_1(self):
contact = Contact(1, 2, 1.0)
contact.define_true_positive()
self.assertTrue(contact.is_true_positive)
self.assertFalse(contact.is_false_positive)

def test_lower_bound(self):
# ======================================================
# Test Case 1
def test_lower_bound_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual(0, contact.lower_bound)
# ======================================================
# Test Case 2

def test_lower_bound_2(self):
contact = Contact(1, 2, 1.0)
with self.assertRaises(ValueError):
contact.lower_bound = -1
# ======================================================
# Test Case 3

def test_lower_bound_3(self):
contact = Contact(1, 2, 1.0)
contact.lower_bound = 1
self.assertEqual(1, contact.lower_bound)
# ======================================================
# Test Case 4

def test_lower_bound_4(self):
contact = Contact(1, 2, 1.0)
contact.lower_bound = 7
self.assertEqual(7, contact.lower_bound)
# ======================================================
# Test Case 5

def test_lower_bound_5(self):
contact = Contact(1, 2, 1.0)
contact.lower_bound = 1
contact.upper_bound = 8
Expand All @@ -82,28 +74,26 @@ def test_lower_bound(self):
contact.lower_bound = 10
self.assertEqual(1, contact.lower_bound)

def test_upper_bound(self):
# ======================================================
# Test Case 1
def test_upper_bound_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual(8, contact.upper_bound)
# ======================================================
# Test Case 2

def test_upper_bound_2(self):
contact = Contact(1, 2, 1.0)
with self.assertRaises(ValueError):
contact.upper_bound = -1
# ======================================================
# Test Case 3

def test_upper_bound_3(self):
contact = Contact(1, 2, 1.0)
contact.upper_bound = 10
self.assertEqual(10, contact.upper_bound)
# ======================================================
# Test Case 4

def test_upper_bound_4(self):
contact = Contact(1, 2, 1.0)
contact.upper_bound = 7
self.assertEqual(7, contact.upper_bound)
# ======================================================
# Test Case 5

def test_upper_bound_5(self):
contact = Contact(1, 2, 1.0)
contact.lower_bound = 4
contact.upper_bound = 8
Expand All @@ -114,9 +104,7 @@ def test_upper_bound(self):
contact.upper_bound = 3
self.assertEqual(8, contact.upper_bound)

def test_raw_score(self):
# ======================================================
# Test Case 1
def test_raw_score_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual(1.0, contact.raw_score)
contact.raw_score = 0.3
Expand All @@ -126,63 +114,53 @@ def test_raw_score(self):
contact.raw_score = 1.0
self.assertEqual(1.0, contact.raw_score)

def test_res1(self):
# ======================================================
# Test Case 1
def test_res1_1(self):
contact = Contact(1, 2, 1.0)
contact.res1 = 'Ala'
self.assertEqual('A', contact.res1)
# ======================================================
# Test Case 2

def test_res1_2(self):
contact = Contact(1, 2, 1.0)
contact.res1 = 'T'
self.assertEqual('T', contact.res1)
# ======================================================
# Test Case 3

def test_res1_3(self):
contact = Contact(1, 2, 1.0)
with self.assertRaises(ValueError):
contact.res1 = '8'

def test_res2(self):
# ======================================================
# Test Case 1
def test_res2_1(self):
contact = Contact(1, 2, 1.0)
contact.res2 = 'Met'
self.assertEqual('M', contact.res2)
# ======================================================
# Test Case 2

def test_res2_2(self):
contact = Contact(1, 2, 1.0)
contact.res2 = 'P'
self.assertEqual('P', contact.res2)
# ======================================================
# Test Case 3

def test_res2_3(self):
contact = Contact(1, 2, 1.0)
with self.assertRaises(ValueError):
contact.res2 = '?'

def test_res1_chain(self):
# ======================================================
# Test Case 1
def test_res1_chain_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual('', contact.res1_chain)
contact.res1_chain = 'A'
self.assertEqual('A', contact.res1_chain)
contact.res1_chain = 'd'
self.assertEqual('d', contact.res1_chain)

def test_res2_chain(self):
# ======================================================
# Test Case 1
def test_res2_chain_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual('', contact.res2_chain)
contact.res2_chain = 'b'
self.assertEqual('b', contact.res2_chain)
contact.res2_chain = 'X'
self.assertEqual('X', contact.res2_chain)

def test_res1_seq(self):
# ======================================================
# Test Case 1
def test_res1_seq_1(self):
contact = Contact(1, 2, 1.0)
self.assertEqual(1, contact.res1_seq)
contact.res1_seq = 2
Expand All @@ -192,9 +170,7 @@ def test_res1_seq(self):
contact.res1_seq = 1
self.assertEqual(1, contact.res1_seq)

def test_res2_seq(self):
# ======================================================
# Test Case 1
def test_res2_seq_1(self):
contact = Contact(1, 2000000, 1.0)
self.assertEqual(2000000, contact.res2_seq)
contact.res2_seq = 1
Expand All @@ -212,63 +188,49 @@ def test_res1_altseq(self):
self.assertEqual(1000, contact.res1_altseq)
self.assertNotEqual(10, contact.res2_altseq)

def test_res2_altseq(self):
# ======================================================
# Test Case 1
def test_res2_altseq_1(self):
contact = Contact(1, 2000000, 1.0)
contact.res2_altseq = 10
self.assertEqual(10, contact.res2_altseq)
self.assertNotEqual(5, contact.res2_altseq)

def test_scalar_score(self):
# ======================================================
# Test Case 1
def test_scalar_score_1(self):
contact = Contact(1, 2000000, 1.0)
contact.scalar_score = 5.432
self.assertEqual(5.432, contact.scalar_score)
# ======================================================
# Test Case 2

def test_scalar_score_2(self):
contact = Contact(1, 2000000, 1.0)
contact.scalar_score = 3
self.assertNotEqual(3, contact.res2_altseq)

def test_status(self):
# ======================================================
# Test Case 1
def test_status_1(self):
contact = Contact(1, 2000000, 1.0)
self.assertEqual(0, contact.status)
contact.define_false_positive()
self.assertEqual(-1, contact.status)
contact.define_true_positive()
self.assertEqual(1, contact.status)

def test_weight(self):
# ======================================================
# Test Case 1
def test_weight_1(self):
contact = Contact(1, 2000000, 1.0)
self.assertEqual(1.0, contact.weight)
contact.weight = 2.5
self.assertEqual(2.5, contact.weight)

def test_define_false_positive(self):
# ======================================================
# Test Case 1
def test_define_false_positive_1(self):
contact = Contact(1, 2, 1.0)
contact.define_false_positive()
self.assertTrue(contact.is_false_positive)
self.assertFalse(contact.is_true_positive)

def test_define_true_positive(self):
# ======================================================
# Test Case 1
def test_define_true_positive_1(self):
contact = Contact(1, 2, 1.0)
contact.define_true_positive()
self.assertTrue(contact.is_true_positive)
self.assertFalse(contact.is_false_positive)

def test__to_dict(self):
# ======================================================
# Test Case 1
def test__to_dict_1(self):
contact = Contact(1, 2, 1.0)
dict = {
'id': (1, 2), 'is_false_positive': False, 'is_true_positive': False, 'distance_bound': (0, 8),
Expand All @@ -277,8 +239,8 @@ def test__to_dict(self):
'status': 0, 'weight': 1.0,
}
self.assertEqual(dict, contact._to_dict())
# ======================================================
# Test Case 2

def test__to_dict_2(self):
contact = Contact(1, 2, 1.0)
contact.define_true_positive()
contact.lower_bound = 4
Expand All @@ -290,7 +252,7 @@ def test__to_dict(self):
}
self.assertEqual(dict, contact._to_dict())

def test__set_residue(self):
def test__set_residue_1(self):
self.assertEqual("A", Contact._set_residue("ALA"))
self.assertEqual("A", Contact._set_residue("Ala"))
self.assertEqual("A", Contact._set_residue("ala"))
Expand Down
Loading

0 comments on commit 189fb48

Please sign in to comment.