Esempio n. 1
0
    def test_watch_config_file(self):
        """The watch command has an eye on the config file. This is an
        extension to the base watch command."""
        try:
            import yaml
        except ImportError:
            raise SkipTest()

        self.cmd_env = CommandLineEnvironment(self.env, logging)
        self.cmd_env.commands['watch'] = \
            GenericArgparseImplementation.WatchCommand(
                self.cmd_env, argparse.Namespace(config=self.path('config.yml')))

        self.create_files({'in': 'foo'})
        template = """
directory: .
bundles:
  foo:
    contents:
        - in
    output: %s
"""
        self.create_files({'config.yml': template % 'outA'})

        with self:
            time.sleep(0.1)
            # Change the config file; this change is detected; we update
            # the timestamp explicitly or we might not have enough precision
            self.create_files({'config.yml': template % 'outB'})
            self.setmtime('config.yml', mod=100)
            time.sleep(0.2)

        # The second output file has been built
        assert self.get('outB') == 'foo'
Esempio n. 2
0
 def test_watch_with_fixed_env_and_no_config(self):
     """[Regression[ The custom 'watch' command does not break if the
     CLI is initialized via fixed environment, instead of reading one from
     a configuration file.
     """
     self.cmd_env = CommandLineEnvironment(self.env, logging)
     self.cmd_env.commands['watch'] = \
         GenericArgparseImplementation.WatchCommand(
             self.cmd_env, argparse.Namespace())
     with self:
         time.sleep(0.1)