예제 #1
0
    def test_get_data_except_exception(self, mock_api):
        mock_api.environment_get.side_effect = Exception('foo_error')

        data_table = tables.UpdateEnvironmentRow(self.mock_data_table)

        with self.assertRaisesRegexp(Exception, 'foo_error'):
            data_table.get_data(None, 'foo_environment_id')
예제 #2
0
    def test_get_data_except_http_not_found(self, mock_api):
        mock_api.environment_get.side_effect = exc.HTTPNotFound

        data_table = tables.UpdateEnvironmentRow(self.mock_data_table)

        with self.assertRaisesRegexp(django_http.Http404, None):
            data_table.get_data(None, 'foo_environment_id')
예제 #3
0
    def test_get_data(self, mock_api):
        mock_api.environment_get.side_effect = None
        mock_api.environment_get.return_value = 'test_environment'

        data_table = tables.UpdateEnvironmentRow(self.mock_data_table)
        environment = data_table.get_data(None, 'foo_environment_id')

        self.assertEqual('test_environment', environment)
        mock_api.environment_get.assert_called_once_with(
            None, 'foo_environment_id')
예제 #4
0
 def test_update_environment_row(self):
     data_table = tables.UpdateEnvironmentRow(self.mock_data_table,
                                              self.mock_datum)
     self.assertEqual('foo_status', data_table.attrs['status'])