Esempio n. 1
0
 def test_destroy_bucket_calls_api_method(self, list_buckets):
     data = {'some': ['json', 'data']}
     list_buckets.return_value = data
     with patch('sys.stdout', StringIO()) as stdout:
         config = json.dumps({'hello': "world"})
         imp('airship.core').main([str(self.tmp), 'list'])
     self.assertEqual(list_buckets.mock_calls, [call()])
     self.assertEqual(json.loads(stdout.getvalue()), data)
Esempio n. 2
0
 def test_destroy_bucket_calls_api_method(self, list_buckets):
     data = {'some': ['json', 'data']}
     list_buckets.return_value = data
     with patch('sys.stdout', StringIO()) as stdout:
         config = json.dumps({'hello': "world"})
         imp('airship.core').main([str(self.tmp), 'list'])
     self.assertEqual(list_buckets.mock_calls, [call()])
     self.assertEqual(json.loads(stdout.getvalue()), data)
Esempio n. 3
0
    def test_init_creates_configuration_and_bin_scripts(self):
        other_tmp = path(tempfile.mkdtemp())
        self.addCleanup(other_tmp.rmtree)

        core = imp('airship.core')
        core.main([str(other_tmp), 'init'])
        expected = ['bin', 'etc', 'var']
        self.assertItemsEqual([f.name for f in other_tmp.listdir()], expected)
        self.assertItemsEqual([f.name for f in (other_tmp / 'bin').listdir()],
                              ['airship', 'supervisord', 'supervisorctl'])
        airship_yaml_path = other_tmp / 'etc' / 'airship.yaml'
        self.assertTrue(airship_yaml_path.isfile())
Esempio n. 4
0
    def test_init_creates_configuration_and_bin_scripts(self):
        other_tmp = path(tempfile.mkdtemp())
        self.addCleanup(other_tmp.rmtree)

        core = imp('airship.core')
        core.main([str(other_tmp), 'init'])
        expected = ['bin', 'etc', 'var']
        self.assertItemsEqual([f.name for f in other_tmp.listdir()], expected)
        self.assertItemsEqual([f.name for f in (other_tmp / 'bin').listdir()],
                              ['airship', 'supervisord', 'supervisorctl'])
        airship_yaml_path = other_tmp / 'etc' / 'airship.yaml'
        self.assertTrue(airship_yaml_path.isfile())
Esempio n. 5
0
    def dispatch(self):
        if self.isStaticRequest():
            return StaticResponse(self.config.ROOT + self.request.path)

        call = imp(self.request.mod, self.request.controller, self.package)
        return call(self.request, *self.request.args)
Esempio n. 6
0
 def test_run_bucket_quotes_its_arguments(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', 'some', 'other thing'])
     self.assertEqual(run.mock_calls, [call("some 'other thing'")])
Esempio n. 7
0
 def test_run_bucket_does_not_require_bucket_id(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', 'a'])
     self.assertEqual(run.mock_calls, [call('a')])
Esempio n. 8
0
 def test_run_bucket_calls_api_method_with_args(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', '-d', bucket.id_, 'a'])
     self.assertEqual(run.mock_calls, [call('a')])
Esempio n. 9
0
 def test_destroy_bucket_calls_api_method(self, destroy):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'destroy', '-d', bucket.id_])
     self.assertEqual(destroy.mock_calls, [call()])
Esempio n. 10
0
 def test_run_bucket_quotes_its_arguments(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', 'some', 'other thing'])
     self.assertEqual(run.mock_calls, [call("some 'other thing'")])
Esempio n. 11
0
 def test_run_bucket_does_not_require_bucket_id(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', 'a'])
     self.assertEqual(run.mock_calls, [call('a')])
Esempio n. 12
0
 def test_run_bucket_calls_api_method_with_args(self, run):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'run', '-d', bucket.id_, 'a'])
     self.assertEqual(run.mock_calls, [call('a')])
Esempio n. 13
0
 def test_destroy_bucket_calls_api_method(self, destroy):
     bucket = self.create_airship().new_bucket()
     imp('airship.core').main([str(self.tmp), 'destroy', '-d', bucket.id_])
     self.assertEqual(destroy.mock_calls, [call()])
Esempio n. 14
0
 def loadApp(appname):
     Config.load(**imp(Config.NAME['CONF'], 'CONFIG', appname))