1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# -*- mode:python; coding:utf-8; tab-width:4 -*-
import sys
import logging
import unittest
import atheist
logging.info("using %s" % atheist.__file__)
sys.path.append('$testdir')
from atheist_mock import Task
class TestFileContains(unittest.TestCase):
def create_condition(self):
return atheist.FileContains('hello', '/tmp/a')
def test_equality(self):
c1 = self.create_condition()
c2 = self.create_condition()
self.assert_(c1 == c2)
def test_insert_FileExists(self):
c = self.create_condition()
task = Task()
task.post += c
newconds = c.pre_task_run(task, task.post)
e = atheist.FileExists('/tmp/a')
# print "-- %s --" % task.post
self.assert_(len(task.pre) == 0)
self.assert_(e in newconds)
self.assert_(newconds.count(e) == 1)
def test_insert_FileExists_in_correct_list(self):
c_pre = atheist.FileContains('foo', '/some/file')
c_post = atheist.FileContains('bar', '/some/file')
task = Task()
task.pre += c_pre
task.post += c_post
pre_newconds = c_pre.pre_task_run(task, task.pre)
post_newconds = c_post.pre_task_run(task, task.post)
e = FileExists('/some/file')
self.assert_(e in pre_newconds)
self.assert_(pre_newconds.count(e) == 1)
self.assert_(e in post_newconds)
self.assert_(post_newconds.count(e) == 1)
def test_insert_FileExists_when_decorated(self):
pass
UnitTestCase(TestFileContains)
|