def test_deploy(self): from cannula.utils import shell, call_subprocess # Fake a remote push g1 = self.api.groups.create('testy', 'abby') p1 = self.api.projects.create(name='test', user='******', group=g1) self.api.projects.initialize(p1, user='******') self.assertTrue(os.path.isfile(p1.post_receive)) # Persist the data in the test db so that external commands (git) can # see the data as well. transaction.commit() cmd = "%s push %s master" % (conf.CANNULA_GIT_CMD, p1.repo_dir) _, cannula_cmd = shell('which cannulactl') self.assertTrue(os.path.isfile('/tmp/cannula_test.db')) env = { 'C_USER': '******', 'DJANGO_SETTINGS_MODULE': 'cannula.test_settings', 'CANNULA_BASE': self.base_dir, 'CANNULA_CMD': cannula_cmd.strip(), 'REPO': 'testy/test.git', } # call_subprocess(cmd, cwd=self.dummy_project, env=env) yaml_file = os.path.join(p1.project_dir, 'app.yaml') self.assertTrue(os.path.isfile(yaml_file))
def call(cls, cmd, cwd=None, env=None, status=0): """ #### `call(cmd)` Call subprocess and check that the exit status matches the expected output. Pass `status=None` to allow ignore all errors. `cwd` specifies the directory to execute in otherwise the current dir is used. `env` allows you to pass a dictionary of environment settings to use. """ st = call_subprocess(cmd, cwd, env) if status is None: return st if st != status: raise RuntimeError("Command Failed: %s" % cmd) return st