Esempio n. 1
0
 def test_inputs(self):
     with patch('slap.cli.config_builder.create_config') as mock:
         cli.main(['init', 'foo', 'bar', 'baz'])
         mock.assert_called_once_with(directories=['foo', 'bar', 'baz'],
                                      filename='config.json',
                                      hostname='hostname',
                                      register_data_sources=False)
Esempio n. 2
0
 def test_publish_inputs(self):
     with patch('slap.publisher.Publisher.publish_input') as mock_publish:
         with patch('slap.publisher.ConfigParser.load_config'):
             input_files = ['foo', 'bar', 'baz']
             cli.main(self.required_args + input_files)
             calls = [call('foo'), call('bar'), call('baz')]
             mock_publish.assert_has_calls(calls)
Esempio n. 3
0
 def test_publish_inputs(self):
     with patch('slap.publisher.Publisher.publish_input') as mock_publish:
         with patch('slap.publisher.ConfigParser.load_config'):
             input_files = ['foo', 'bar', 'baz']
             cli.main(self.required_args + input_files)
             calls = [call('foo'), call('bar'), call('baz')]
             mock_publish.assert_has_calls(calls)
Esempio n. 4
0
 def test_default_args(self):
     with patch('slap.cli.config_builder.create_config') as mock:
         cli.main(['init'])
         mock.assert_called_once_with(directories=[os.getcwd()],
                                      filename='config.json',
                                      hostname='hostname',
                                      register_data_sources=False)
Esempio n. 5
0
 def test_default_args(self):
     with patch('slap.cli.config_builder.create_config') as mock:
         cli.main(['init'])
         mock.assert_called_once_with(
             directories=[os.getcwd()],
             filename='config.json',
             hostname='hostname',
             register_data_sources=False
         )
Esempio n. 6
0
 def test_uses_git_if_both_git_and_inputs_specified(self):
     expected = 'bar'
     with patch('slap.publisher.ConfigParser.load_config'):
         with patch('slap.publisher.Publisher.publish_input') as mock_publish:
             with patch('slap.git.get_changed_mxds') as mock_changed:
                 mock_changed.return_value = [expected]
                 cli.main(['publish', '-u', 'user', '-p', 'pass', '-g', 'some-hash', 'foo'])
                 mock_changed.assert_called_once_with('some-hash')
                 mock_publish.assert_called_once_with(expected)
Esempio n. 7
0
 def test_inputs(self):
     with patch('slap.cli.config_builder.create_config') as mock:
         cli.main(['init', 'foo', 'bar', 'baz'])
         mock.assert_called_once_with(
             directories=['foo', 'bar', 'baz'],
             filename='config.json',
             hostname='hostname',
             register_data_sources=False
         )
Esempio n. 8
0
 def test_publish_git(self):
     with patch('slap.cli.Publisher.publish_input') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             with patch('slap.git.get_changed_mxds') as mock_git:
                 sha = 'some-hash'
                 file = 'some/file'
                 mock_git.return_value = [file]
                 cli.main(self.required_args + ['-g', sha])
                 mock_git.assert_called_once_with(sha)
                 mock_publisher.assert_called_once_with(file)
Esempio n. 9
0
 def test_publish_git(self):
     with patch('slap.cli.Publisher.publish_input') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             with patch('slap.git.get_changed_mxds') as mock_git:
                 sha = 'some-hash'
                 file = 'some/file'
                 mock_git.return_value = [file]
                 cli.main(self.required_args + ['-g', sha])
                 mock_git.assert_called_once_with(sha)
                 mock_publisher.assert_called_once_with(file)
Esempio n. 10
0
 def test_uses_git_if_both_git_and_inputs_specified(self):
     expected = 'bar'
     with patch('slap.publisher.ConfigParser.load_config'):
         with patch(
                 'slap.publisher.Publisher.publish_input') as mock_publish:
             with patch('slap.git.get_changed_mxds') as mock_changed:
                 mock_changed.return_value = [expected]
                 cli.main([
                     'publish', '-u', 'user', '-p', 'pass', '-g',
                     'some-hash', 'foo'
                 ])
                 mock_changed.assert_called_once_with('some-hash')
                 mock_publish.assert_called_once_with(expected)
Esempio n. 11
0
 def test_create_site(self):
     with patch('slap.api.Api.create_site') as mock_create_site:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args + ['-s'])
             mock_create_site.assert_called_once()
Esempio n. 12
0
 def test_publish_all(self):
     with patch('slap.publisher.Publisher.publish_all') as mock_publish:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args)
             mock_publish.assert_called_once()
Esempio n. 13
0
 def test_register_data_sources(self):
     with patch('slap.publisher.Publisher.register_data_sources') as mock_register:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args)
             mock_register.assert_called_once()
Esempio n. 14
0
 def test_set_hostname(self):
     with patch('slap.cli.Publisher') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args + ['-n', 'host'])
             mock_publisher.assert_called_once_with('user', 'pass', 'config.json', 'host')
Esempio n. 15
0
 def test_uses_default_config(self):
     with patch('slap.cli.Publisher') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(['publish', '-u', 'user', '-p', 'pass'])
             mock_publisher.assert_called_once_with('user', 'pass', 'config.json', None)
Esempio n. 16
0
 def test_register_data_sources(self):
     with patch('slap.publisher.Publisher.register_data_sources'
                ) as mock_register:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args)
             mock_register.assert_called_once()
Esempio n. 17
0
 def test_throws_if_no_password(self):
     with self.assertRaises(SystemExit):
         cli.main(['publish', '-u', 'user', '-c', 'config.json'])
Esempio n. 18
0
 def test_set_hostname(self):
     with patch('slap.cli.Publisher') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args + ['-n', 'host'])
             mock_publisher.assert_called_once_with('user', 'pass',
                                                    'config.json', 'host')
Esempio n. 19
0
 def test_throws_if_no_username(self):
     with self.assertRaises(SystemExit):
         cli.main(['publish', '-c', 'config.json', '-p', 'pass'])
Esempio n. 20
0
 def test_throws_if_no_password(self):
     with self.assertRaises(SystemExit):
         cli.main(['publish', '-u', 'user', '-c', 'config.json'])
Esempio n. 21
0
 def test_create_site(self):
     with patch('slap.api.Api.create_site') as mock_create_site:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args + ['-s'])
             mock_create_site.assert_called_once()
Esempio n. 22
0
 def test_publish_all(self):
     with patch('slap.publisher.Publisher.publish_all') as mock_publish:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(self.required_args)
             mock_publish.assert_called_once()
Esempio n. 23
0
 def test_throws_if_no_username(self):
     with self.assertRaises(SystemExit):
         cli.main(['publish', '-c', 'config.json', '-p', 'pass'])
Esempio n. 24
0
 def test_uses_default_config(self):
     with patch('slap.cli.Publisher') as mock_publisher:
         with patch('slap.publisher.ConfigParser.load_config'):
             cli.main(['publish', '-u', 'user', '-p', 'pass'])
             mock_publisher.assert_called_once_with('user', 'pass',
                                                    'config.json', None)