def test_mockclient(minion_opts, template_dir, hello_simple, get_loader): """ A MockFileClient is used that records all file requests normally sent to the master. """ loader = get_loader(opts=minion_opts, saltenv="test") res = loader.get_source(None, "hello_simple") assert len(res) == 3 # res[0] on Windows is unicode and use os.linesep so it works cross OS assert str(res[0]) == "world" + os.linesep assert res[1] == str(hello_simple) assert res[2](), "Template up to date?" assert loader._file_client.requests assert loader._file_client.requests[0]["path"] == "salt://hello_simple"
def test_mockclient(self): ''' A MockFileClient is used that records all file requests normally sent to the master. ''' loader = self.get_loader(opts=self.opts, saltenv='test') res = loader.get_source(None, 'hello_simple') assert len(res) == 3 # res[0] on Windows is unicode and use os.linesep so it works cross OS self.assertEqual(str(res[0]), 'world' + os.linesep) tmpl_dir = os.path.join(self.TEMPLATES_DIR, 'hello_simple') self.assertEqual(res[1], tmpl_dir) assert res[2](), 'Template up to date?' assert len(loader._file_client.requests) self.assertEqual(loader._file_client.requests[0]['path'], 'salt://hello_simple')
def test_mockclient(self): ''' A MockFileClient is used that records all file requests normally sent to the master. ''' loader = SaltCacheLoader({'cachedir': TEMPLATES_DIR}, 'test') fc = MockFileClient(loader) res = loader.get_source(None, 'hello_simple') assert len(res) == 3 # res[0] on Windows is unicode and use os.linesep so it works cross OS self.assertEqual(str(res[0]), 'world' + os.linesep) tmpl_dir = os.path.join(TEMPLATES_DIR, 'files', 'test', 'hello_simple') self.assertEqual(res[1], tmpl_dir) assert res[2](), 'Template up to date?' assert len(fc.requests) self.assertEqual(fc.requests[0]['path'], 'salt://hello_simple')
def test_mockclient(self): ''' A MockFileClient is used that records all file requests normally sent to the master. ''' loader = SaltCacheLoader(self.opts, 'test') fc = MockFileClient(loader) res = loader.get_source(None, 'hello_simple') assert len(res) == 3 # res[0] on Windows is unicode and use os.linesep so it works cross OS self.assertEqual(str(res[0]), 'world' + os.linesep) tmpl_dir = os.path.join(TEMPLATES_DIR, 'files', 'test', 'hello_simple') self.assertEqual(res[1], tmpl_dir) assert res[2](), 'Template up to date?' assert len(fc.requests) self.assertEqual(fc.requests[0]['path'], 'salt://hello_simple')