Exemplo n.º 1
0
 def start_patchers(self, fake_fs):
     fake_fns = make_fake_fstools(fake_fs)
     # relies on fake_fns being in same order as patchpoints
     for ppoint, fn in zip(self.__class__.patchpoints, fake_fns):
         self.mocks[ppoint].side_effect = fn
     for patcher in self.patchers.values():
         patcher.start()
Exemplo n.º 2
0
 def start_patchers(self, fake_fs):
     fake_fns = make_fake_fstools(fake_fs)
     # relies on fake_fns being in same order as patchpoints
     for ppoint, fn in zip(self.__class__.patchpoints, fake_fns):
         self.mocks[ppoint].side_effect = fn
     for patcher in self.patchers.values():
         patcher.start()
Exemplo n.º 3
0
def test_extract_info_dir(m_isdir, m_open):
    simple_fs = {'a': {'b.yaml': 'meta: [{foo: c}]'}}
    _, _, _, m_isdir.side_effect, m_open.side_effect = \
        make_fake_fstools(simple_fs)
    info = extract_info('a', [])
    assert info == {}

    info = extract_info('a', ['foo', 'bar'])
    assert info == {'foo': '', 'bar': ''}

    info = extract_info('a/b.yaml', ['foo', 'bar'])
    assert info == {'foo': 'c', 'bar': ''}
Exemplo n.º 4
0
 def setup(self):
     self.mocks = dict()
     self.patchers = dict()
     exists, listdir, isfile, isdir, open = make_fake_fstools(realistic_fs)
     for ppoint, fn in {
          'os.listdir': listdir,
          'os.path.isdir': isdir,
          'teuthology.describe_tests.open': open,
          'os.path.exists': exists,
          'os.listdir': listdir,
          'os.path.isfile': isfile,
      }.items():
         mockobj = MagicMock()
         patcher = patch(ppoint, mockobj)
         mockobj.side_effect = fn
         patcher.start()
         self.mocks[ppoint] = mockobj
         self.patchers[ppoint] = patcher
Exemplo n.º 5
0
def test_extract_info_empty_file(m_isdir, m_open):
    simple_fs = {'a.yaml': ''}
    _, _, _, m_isdir.side_effect, m_open.side_effect = \
        make_fake_fstools(simple_fs)
    info = extract_info('a.yaml', [])
    assert info == {}
Exemplo n.º 6
0
def check_parse_error(fs, m_isdir, m_open):
    _, _, _, m_isdir.side_effect, m_open.side_effect = make_fake_fstools(fs)
    with pytest.raises(ParseError):
        a = extract_info('a.yaml', ['a'])
        raise Exception(str(a))