| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
# not use this file except in compliance with the License. You may obtain |
| 5 |
# a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 |
# License for the specific language governing permissions and limitations |
| 13 |
# under the License. |
| 14 |
|
| 15 |
""" |
| 16 |
test_sphinx_feature_classification |
| 17 |
---------------------------------- |
| 18 |
|
| 19 |
Tests for `sphinx_feature_classification` module. |
| 20 |
""" |
| 21 |
import configparser |
| 22 |
import os |
| 23 |
|
| 24 |
import ddt |
| 25 |
import fixtures |
| 26 |
|
| 27 |
from sphinx_feature_classification import support_matrix |
| 28 |
from sphinx_feature_classification.tests import base |
| 29 |
|
| 30 |
|
| 31 |
@ddt.ddt |
| 32 |
class MatrixTestCase(base.TestCase): |
| 33 |
|
| 34 |
def setUp(self): |
| 35 |
super(MatrixTestCase, self).setUp() |
| 36 |
|
| 37 |
cfg = configparser.ConfigParser() |
| 38 |
directory = os.path.dirname(os.path.abspath(__file__)) |
| 39 |
config_file = os.path.join(directory, 'fakes', 'support-matrix.ini') |
| 40 |
|
| 41 |
with open(config_file) as fp: |
| 42 |
cfg.read_file(fp) |
| 43 |
|
| 44 |
self.matrix = support_matrix.Matrix(cfg) |
| 45 |
|
| 46 |
def test_features_set(self): |
| 47 |
fake_feature = self.matrix.features[0] |
| 48 |
self.assertEqual('Cool Feature', fake_feature.title) |
| 49 |
self.assertEqual('optional', fake_feature.status) |
| 50 |
self.assertEqual('openstack get coolness *', fake_feature.cli) |
| 51 |
self.assertEqual('get-coolness', fake_feature.api) |
| 52 |
self.assertEqual('A pretty darn cool feature.', |
| 53 |
fake_feature.notes) |
| 54 |
|
| 55 |
@ddt.unpack |
| 56 |
@ddt.data({'key': 'driver.foo', 'title': 'Foo Driver', |
| 57 |
'link': 'https://docs.openstack.org'}, |
| 58 |
{'key': 'driver.bar', 'title': 'Bar Driver', |
| 59 |
'link': 'https://docs.openstack.org'}) |
| 60 |
def test_drivers_set(self, key, title, link): |
| 61 |
fake_driver = self.matrix.drivers[key] |
| 62 |
self.assertEqual(title, fake_driver.title) |
| 63 |
self.assertEqual(link, fake_driver.link) |
| 64 |
|
| 65 |
@ddt.unpack |
| 66 |
@ddt.data({'key': 'driver.foo', 'status': 'complete', |
| 67 |
'notes': None}, |
| 68 |
{'key': 'driver.bar', 'status': 'partial', |
| 69 |
'notes': 'Requires hardware support.'}) |
| 70 |
def test_implementations_set(self, key, status, notes): |
| 71 |
fake_implementation = self.matrix.features[0].implementations[key] |
| 72 |
self.assertEqual(status, fake_implementation.status) |
| 73 |
self.assertEqual(notes, fake_implementation.notes) |
| 74 |
|
| 75 |
def test_on_build_finished(self): |
| 76 |
|
| 77 |
class FakeApp(object): |
| 78 |
outdir = self.useFixture(fixtures.TempDir()).path |
| 79 |
|
| 80 |
app = FakeApp() |
| 81 |
exc = None |
| 82 |
support_matrix.on_build_finished(app, exc) |
| 83 |
expected_file = os.path.join( |
| 84 |
app.outdir, '_static', 'support-matrix.css') |
| 85 |
self.assertTrue(os.path.isfile(expected_file)) |