Пример #1
0
	def test_should_scan_for_state_if_not_given_any(self):
		watcher = Watcher()
		state = mock('state').with_children(good=[],bad=[],affected=[])
		config = mock('config').with_children(autonose=True)
		mock_on(watcher_module.scanner).scan.is_expected.once().returning(state.raw)
		watcher_module.global_state = None
		watcher.configure(config.raw)
Пример #2
0
	def test_should_be_enabled_when_given___autonose_option(self):
		watcher = Watcher()
		self.assertFalse(watcher.enabled)
		config = mock('config').with_children(autonose=True)
		watcher.configure(config.raw)
		mock_on(watcher)._setup
		self.assertTrue(watcher.enabled)
Пример #3
0
    def test_should_only_run_affected_and_bad_files(self):
        # have to use an object with a path for debugging purposes - not ideal..
        class Num(object):
            def __init__(self, n):
                self.n = n
                self.path = "PATH"

            def __repr__(self):
                return repr(self.n)

            def __str__(self):
                return str(self.n)

            def __eq__(self, other):
                return self.n == other.n

        watcher = Watcher()
        good = set(map(Num, [1, 2, 3]))
        bad = set(map(Num, [4, 5, 6]))
        changed = set(map(Num, [7, 8, 9]))
        affected = set(map(Num, [10, 11, 12]))
        state = mock('state').with_children(good=good,
                                            bad=bad,
                                            changed=changed,
                                            affected=affected)
        config = mock('config').with_children(autonose=True)
        mock_on(watcher_module).scanner.expects('scan').once().returning(
            state.raw)
        watcher.configure(config.raw)

        self.assertEqual(watcher.files_to_run, bad.union(affected))
Пример #4
0
 def test_should_scan_for_state_if_not_given_any(self):
     watcher = Watcher()
     state = mock('state').with_children(good=[], bad=[], affected=[])
     config = mock('config').with_children(autonose=True)
     mock_on(watcher_module.scanner).scan.is_expected.once().returning(
         state.raw)
     watcher.configure(config.raw)
Пример #5
0
 def test_should_be_enabled_when_given___autonose_option(self):
     watcher = Watcher()
     self.assertFalse(watcher.enabled)
     config = mock('config').with_children(autonose=True)
     watcher.configure(config.raw)
     mock_on(watcher)._setup
     self.assertTrue(watcher.enabled)
Пример #6
0
	def test_should_only_run_affected_and_bad_files(self):
		# have to use an object with a path for debugging purposes - not ideal..
		class Num(object):
			def __init__(self, n):
				self.n = n
				self.path = "PATH"
			def __repr__(self): return repr(self.n)
			def __str__(self):  return str(self.n)
			def __eq__(self, other): return self.n == other.n
		watcher = Watcher()
		good = set(map(Num, [1,2,3]))
		bad = set(map(Num, [4,5,6]))
		changed = set(map(Num, [7,8,9]))
		affected = set(map(Num, [10,11,12]))
		state = mock('state').with_children(good=good, bad=bad, changed=changed, affected=affected)
		config = mock('config').with_children(autonose=True)
		mock_on(watcher_module).scanner.expects('scan').once().returning(state.raw)
		watcher.configure(config.raw)
		
		self.assertEqual(watcher.files_to_run, bad.union(affected))