Пример #1
0
 def test_get_module_paths_domain_dne_throws(self):
     '''Should error when a domain path does not exist.'''
     host_cfg = HostConfig(None, None)
     host_cfg.domains = [self.root / 'dne']
     host_cfg.modules = ['mod']
     mod_gen = get_module_paths(host_cfg)
     with self.assertRaises(FileNotFoundError):
         next(mod_gen)
Пример #2
0
 def test_get_module_paths_module_dne_ignore(self):
     '''Should ignore a module path that does not exist.'''
     host_cfg = HostConfig(None, None)
     host_cfg.domains = [self.root / 'dom1']
     host_cfg.modules = ['mod']
     (self.root / 'dom1').mkdir()
     mod_gen = get_module_paths(host_cfg)
     with self.assertRaises(StopIteration):
         next(mod_gen)
Пример #3
0
 def test_get_module_paths_domain_is_file_throws(self):
     '''Should error when a domain path points to a file.'''
     host_cfg = HostConfig(None, None)
     host_cfg.domains = [self.root / 'is_file']
     host_cfg.modules = ['mod']
     (self.root / 'is_file').touch()
     mod_gen = get_module_paths(host_cfg)
     with self.assertRaises(NotADirectoryError):
         next(mod_gen)
Пример #4
0
 def test_get_module_paths_duplicate_domain_throws(self):
     '''Should error when a domain path is duplicated.'''
     host_cfg = HostConfig(None, None)
     host_cfg.domains = [
         self.root / 'seeingdouble', self.root / 'seeingdouble'
     ]
     host_cfg.modules = ['mod']
     (self.root / 'seeingdouble').mkdir()
     mod_gen = get_module_paths(host_cfg)
     with self.assertRaises(DuplicateDomainError):
         next(mod_gen)
Пример #5
0
 def test_get_module_paths_correct_order(self):
     '''Should return module paths in order, skipping if dne.'''
     host_cfg = HostConfig(None, None)
     host_cfg.domains = [self.root / 'dom1', self.root / 'dom2']
     host_cfg.modules = ['mod1', 'mod2']
     (self.root / 'dom1').mkdir()
     (self.root / 'dom2').mkdir()
     (self.root / 'dom1' / 'mod1').mkdir()
     (self.root / 'dom1' / 'mod2').mkdir()
     (self.root / 'dom2' / 'mod2').mkdir()
     mod_gen = get_module_paths(host_cfg)
     self.assertEqual(
         [next(mod_gen), next(mod_gen),
          next(mod_gen)], [
              self.root / 'dom1' / 'mod1', self.root / 'dom1' / 'mod2',
              self.root / 'dom2' / 'mod2'
          ])
     with self.assertRaises(StopIteration):
         next(mod_gen)