def test_01_facter(self): f = Facter() facts = f.facts() self.assertTrue(isinstance(facts, dict)) self.assertTrue(facts.has_key('uptime'))
def test_fetch_all(self): f = Facter() facts = f.facts() self.assertTrue(isinstance(facts, dict)) self.assertTrue(facts.has_key('architecture')) self.assertTrue(facts.has_key('ipaddress')) self.assertTrue(facts.has_key('fqdn'))
def test_fetch_filter(self): f = Facter() key_filter = [ re.compile(r"arch"), re.compile(r"fqdn"), re.compile(r"ip"), ] filtered = f.facts(key_filter=key_filter) self.assertTrue(isinstance(filtered, dict)) self.assertTrue(filtered.has_key('architecture')) self.assertTrue(filtered.has_key('ipaddress')) self.assertTrue(filtered.has_key('fqdn'))
def test_cache_facter(self): f1 = Facter() f2 = Facter() f1facts = f1.facts() f2facts = f2.facts() self.assertEqual(f1facts['fqdn'], f2facts['fqdn']) self.assertTrue(Facter.__FACTER_HANDLER__) f1.clear() self.assertFalse(Facter.__FACTER_HANDLER__)
def test_00_no_facter(self): f = Facter(facter="/no/such/file/facter") self.assertEqual(f.facts(), {})