Exemplo n.º 1
0
	def test_branches(self):
		confRegEx = mock.MagicMock(return_value=re.compile('^(.*\\-command|Git|DEFAULT|Database)$'))
		with mock.patch('gitdh.module.ModuleLoader.getConfRegEx', new=confRegEx):
			c = Config()
			c.read_string(self.cStr)

			self.assertTrue(isinstance(c.branches, ConfigBranches))

			self.assertEqual(len(c.branches), 2)

			self.assertNotIn('feature-xyz', c.branches)
			self.assertNotIn('Git', c.branches)
			self.assertNotIn('Database', c.branches)
			self.assertNotIn('DEFAULT', c.branches)
			self.assertNotIn('crunch-command', c.branches)
			self.assertIn('development', c.branches)
			self.assertIn('master', c.branches)

			self.assertRaises(KeyError, lambda: c.branches['feature-xyz'])
			self.assertRaises(KeyError, lambda: c.branches['Git'])
			self.assertRaises(KeyError, lambda: c.branches['Database'])
			self.assertRaises(KeyError, lambda: c.branches['DEFAULT'])
			self.assertRaises(KeyError, lambda: c.branches['crunch-command'])

			self.assertSetEqual(set((i for i in c.branches)), set(('development', 'master')))

			self.assertIsInstance(c.branches['development'], SectionProxy)
			self.assertIn('Path', c.branches['development'])

			self.assertNotIn('External', c.branches['development'])
			c['development']['External'] = 'False'
			self.assertIn('External', c.branches['development'])

			confRegEx.assert_called_once_with()
Exemplo n.º 2
0
	def test_command(self):
		c = Config()
		c.read_string(self.cStr)

		self.assertTrue('crunch-command' in c)
		sct = c['crunch-command']
		self.assertIsInstance(sct, SectionProxy)
		self.assertEqual(sct['Mode'], 'perfile')
		self.assertEqual(sct['RegExp'], '\.php$')
		self.assertEqual(sct['Command'], 'eff_php_crunch ${f}')