Kaynağa Gözat

doc-tools unit tests

Renamed sitemap file to avoid module name conflict
when importing at the sitemap unittest

Added py.test tox environment

Change-Id: I94480e374b29802414b62591a51c04ecd804905e
Closes-Bug: #1387716
tags/1.0.0
Percila 3 yıl önce
ebeveyn
işleme
c050836a8f

+ 1
- 0
.gitignore Dosyayı Görüntüle

@@ -14,6 +14,7 @@ sdist
14 14
 # Unit test / coverage reports
15 15
 .coverage
16 16
 .tox
17
+.testrepository
17 18
 
18 19
 # pbr generates these
19 20
 AUTHORS

+ 7
- 0
.testr.conf Dosyayı Görüntüle

@@ -0,0 +1,7 @@
1
+[DEFAULT]
2
+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3
+             OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4
+             OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
5
+             ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
6
+test_id_option=--load-list $IDFILE
7
+test_list_option=--list

+ 1
- 2
HACKING.rst Dosyayı Görüntüle

@@ -9,8 +9,7 @@ openstack-doc-tools style commandments
9 9
 Running tests
10 10
 -------------
11 11
 
12
-So far there are no tests included with the package but a test suite
13
-would be welcome!
12
+So far there are some tests included with the package.
14 13
 
15 14
 The openstack-indexpage tool is used while building the OpenStack
16 15
 documentation repositories, test building of these repositories with

+ 1
- 0
bin/doc-tools-update-cli-reference Dosyayı Görüntüle

@@ -89,6 +89,7 @@ branch=cli-reference
89 89
 git branch --list $branch && git branch -D $branch
90 90
 git checkout -b $branch
91 91
 mv ../output/${project}.rst "doc/cli-reference/source"
92
+rm -rf ../output
92 93
 version=$($project --version 2>&1)
93 94
 version=${version##*\)}
94 95
 git commit -a -m "[cli-ref] Update python-${project}client to ${version##* }"

+ 0
- 3
os_doc_tools/commands.py Dosyayı Görüntüle

@@ -741,9 +741,6 @@ def document_single_project(os_command, output_dir, continue_on_error):
741 741
                                           ["--os-image-api-version", "1"],
742 742
                                           "_v1", " (v1)")
743 743
 
744
-    if os_command == 'glance':
745
-        out_file.write(".. include:: glance_property_keys.rst\n")
746
-
747 744
     print("Finished.\n")
748 745
     out_file.close()
749 746
     return True

+ 0
- 0
os_doc_tools/test/__init__.py Dosyayı Görüntüle


+ 37
- 0
os_doc_tools/test/test_index.py Dosyayı Görüntüle

@@ -0,0 +1,37 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import mock
14
+from os_doc_tools import index
15
+import unittest
16
+
17
+
18
+class TestGenerateIndex(unittest.TestCase):
19
+    def test_dir_created(self):
20
+        path = 'path'
21
+        with mock.patch.object(index, 'open'):
22
+            with mock.patch.object(index.os, 'mkdir') as mock_mkdir:
23
+                index.generate_index_file(path)
24
+        self.assertTrue(mock_mkdir.called)
25
+
26
+    def test_dir_not_created_when_exists(self):
27
+        path = 'path'
28
+        with mock.patch.object(index, 'open'):
29
+            with mock.patch.object(index.os, 'mkdir') as mock_mkdir:
30
+                with mock.patch.object(index.os.path, 'isdir',
31
+                                       returned_value=True):
32
+                    index.generate_index_file(path)
33
+        self.assertFalse(mock_mkdir.called)
34
+
35
+
36
+if __name__ == '__main__':
37
+    unittest.main()

+ 98
- 0
os_doc_tools/test/test_jsoncheck.py Dosyayı Görüntüle

@@ -0,0 +1,98 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import mock
14
+from os_doc_tools import jsoncheck
15
+import unittest
16
+
17
+
18
+class MockOpen(object):
19
+
20
+    def read(self):
21
+        return "raw"
22
+
23
+    def write(self):
24
+        return True
25
+
26
+
27
+class TestFileFunctions(unittest.TestCase):
28
+
29
+    def test_indent_note(self):
30
+        note = "Hello\nWorld"
31
+        with mock.patch.object(jsoncheck.textwrap, 'fill') as mock_fill:
32
+            mock_fill.return_value = "Hello World"
33
+            jsoncheck._indent_note(note)
34
+            mock_fill.assert_any_call('Hello', initial_indent='    ',
35
+                                      subsequent_indent='            ',
36
+                                      width=80)
37
+            mock_fill.assert_any_call('World', initial_indent='    ',
38
+                                      subsequent_indent='            ',
39
+                                      width=80)
40
+
41
+    def test_get_demjson_diagnostics(self):
42
+        raw = "raw"
43
+
44
+        with mock.patch.object(jsoncheck.demjson, 'decode', return_value=True):
45
+            errstr = jsoncheck._get_demjson_diagnostics(raw)
46
+            self.assertTrue(errstr is None)
47
+
48
+        with mock.patch.object(jsoncheck.demjson, 'decode') as mock_decode:
49
+            mock_decode.side_effect = jsoncheck.demjson.JSONError(raw)
50
+            errstr = jsoncheck._get_demjson_diagnostics(raw)
51
+            expected_error_str = "     Error: raw"
52
+            self.assertEqual(errstr, expected_error_str)
53
+
54
+    def test_parse_json(self):
55
+        raw = "raw"
56
+        with mock.patch.object(jsoncheck.json, 'loads',
57
+                               return_value="Success"):
58
+            parsed = jsoncheck._parse_json(raw)
59
+        self.assertEqual(parsed, "Success")
60
+
61
+        with mock.patch.object(jsoncheck.json, 'loads') as mock_loads:
62
+            mock_loads.side_effect = ValueError()
63
+            with self.assertRaises(jsoncheck.ParserException):
64
+                parsed = jsoncheck._parse_json(raw)
65
+
66
+    def test_format_parsed_json(self):
67
+        with mock.patch.object(jsoncheck.json, 'dumps') as mock_dumps:
68
+            mock_dumps.return_value = "Success"
69
+            returned_value = jsoncheck._format_parsed_json('raw')
70
+        self.assertEqual(returned_value, "Success\n")
71
+        self.assertTrue(mock_dumps.called)
72
+
73
+    def test_process_file(self):
74
+        with mock.patch.object(jsoncheck, 'open', returned_value=MockOpen()):
75
+            with mock.patch.object(jsoncheck, '_parse_json') as mock_parse:
76
+                mock_parse.side_effect = jsoncheck.ParserException
77
+                with self.assertRaises(ValueError):
78
+                    jsoncheck._process_file('path')
79
+
80
+        with mock.patch.object(jsoncheck, 'open', returned_value=MockOpen()):
81
+            with mock.patch.object(jsoncheck, '_parse_json',
82
+                                   returned_value="Success"):
83
+                with mock.patch.object(jsoncheck, '_format_parsed_json',
84
+                                       returned_value="not_raw"):
85
+                        with self.assertRaises(ValueError):
86
+                            jsoncheck._process_file('path', 'check')
87
+
88
+        with mock.patch.object(jsoncheck, 'open', returned_value=MockOpen()):
89
+            with mock.patch.object(jsoncheck, '_parse_json',
90
+                                   returned_value="Success"):
91
+                with mock.patch.object(jsoncheck, '_format_parsed_json',
92
+                                       returned_value="not_raw"):
93
+                    with self.assertRaises(ValueError):
94
+                        jsoncheck._process_file('path', 'formatting')
95
+
96
+
97
+if __name__ == '__main__':
98
+    unittest.main()

+ 0
- 0
sitemap/__init__.py Dosyayı Görüntüle


sitemap/generator/spiders/sitemap.py → sitemap/generator/spiders/sitemap_file.py Dosyayı Görüntüle

@@ -13,9 +13,9 @@
13 13
 import time
14 14
 import urlparse
15 15
 
16
-from generator import items
17 16
 from scrapy.linkextractors import LinkExtractor
18 17
 from scrapy import spiders
18
+from sitemap.generator import items
19 19
 
20 20
 
21 21
 class SitemapSpider(spiders.CrawlSpider):

+ 0
- 0
sitemap/test/__init__.py Dosyayı Görüntüle


+ 110
- 0
sitemap/test/generator/spiders/test_sitemap_file.py Dosyayı Görüntüle

@@ -0,0 +1,110 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import mock
14
+from sitemap.generator.spiders import sitemap_file
15
+import unittest
16
+
17
+
18
+class TestSitemapSpider(unittest.TestCase):
19
+
20
+    def setUp(self):
21
+        self.spider = sitemap_file.SitemapSpider()
22
+
23
+    def test_set_vars_on_init(self):
24
+        domain = 'docs.openstack.org'
25
+        self.assertEqual(self.spider.domain, domain)
26
+        self.assertEqual(self.spider.allowed_domains, [domain])
27
+        self.assertEqual(self.spider.start_urls, ['http://%s' % domain])
28
+
29
+    def test_start_urls_get_appended(self):
30
+        urls = 'new.openstack.org, old.openstack.org'
31
+        urls_len = len(urls.split(','))
32
+        spider_len = len(self.spider.start_urls)
33
+
34
+        spider_with_urls = sitemap_file.SitemapSpider(urls=urls)
35
+        spider_with_urls_len = len(spider_with_urls.start_urls)
36
+
37
+        self.assertEqual(spider_with_urls_len, (urls_len + spider_len))
38
+
39
+    def test_parse_items_inits_sitemap(self):
40
+        response = mock.MagicMock()
41
+        with mock.patch.object(sitemap_file.items,
42
+                               'SitemapItem') as mocked_sitemap_item:
43
+            with mock.patch.object(sitemap_file, 'time'):
44
+                self.spider.parse_item(response)
45
+
46
+        self.assertTrue(mocked_sitemap_item.called)
47
+
48
+    def test_parse_items_gets_path(self):
49
+        response = mock.MagicMock()
50
+        with mock.patch.object(sitemap_file.items, 'SitemapItem'):
51
+            with mock.patch.object(sitemap_file.urlparse,
52
+                                   'urlsplit') as mocked_urlsplit:
53
+                with mock.patch.object(sitemap_file, 'time'):
54
+                    self.spider.parse_item(response)
55
+
56
+        self.assertTrue(mocked_urlsplit.called)
57
+
58
+    def test_parse_items_low_priority_weekly_freq(self):
59
+        response = mock.MagicMock()
60
+        path = sitemap_file.urlparse.SplitResult(
61
+            scheme='https',
62
+            netloc='docs.openstack.com',
63
+            path='/kilo',
64
+            query='',
65
+            fragment=''
66
+        )
67
+        with mock.patch.object(sitemap_file.urlparse, 'urlsplit',
68
+                               return_value=path):
69
+            with mock.patch.object(sitemap_file, 'time'):
70
+                returned_item = self.spider.parse_item(response)
71
+
72
+        self.assertEqual('0.5', returned_item['priority'])
73
+        self.assertEqual('weekly', returned_item['changefreq'])
74
+
75
+    def test_parse_items_high_priority_daily_freq(self):
76
+        response = mock.MagicMock()
77
+        path = sitemap_file.urlparse.SplitResult(
78
+            scheme='https',
79
+            netloc='docs.openstack.com',
80
+            path='/mitaka',
81
+            query='',
82
+            fragment=''
83
+        )
84
+        with mock.patch.object(sitemap_file.urlparse, 'urlsplit',
85
+                               return_value=path):
86
+            with mock.patch.object(sitemap_file, 'time'):
87
+                returned_item = self.spider.parse_item(response)
88
+
89
+        self.assertEqual('1.0', returned_item['priority'])
90
+        self.assertEqual('daily', returned_item['changefreq'])
91
+
92
+    def test_parse_returns_populated_item(self):
93
+        response = mock.MagicMock()
94
+        path = sitemap_file.urlparse.SplitResult(
95
+            scheme='https',
96
+            netloc='docs.openstack.com',
97
+            path='/mitaka',
98
+            query='',
99
+            fragment=''
100
+        )
101
+        with mock.patch.object(sitemap_file.urlparse, 'urlsplit',
102
+                               return_value=path):
103
+            with mock.patch.object(sitemap_file, 'time'):
104
+                returned_item = self.spider.parse_item(response)
105
+
106
+        self.assertEqual(4, len(returned_item))
107
+
108
+
109
+if __name__ == '__main__':
110
+    unittest.main()

+ 37
- 0
sitemap/test/generator/test_items.py Dosyayı Görüntüle

@@ -0,0 +1,37 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import mock
14
+from sitemap.generator import items
15
+import unittest
16
+
17
+
18
+class TestSitemapItem(unittest.TestCase):
19
+
20
+    def test_class_type(self):
21
+        self.assertTrue(type(items.SitemapItem) is items.scrapy.item.ItemMeta)
22
+
23
+    def test_class_supports_fields(self):
24
+        with mock.patch.object(items.scrapy.item, 'Field'):
25
+            a = items.SitemapItem()
26
+
27
+        supported_fields = ['loc', 'lastmod', 'priority', 'changefreq']
28
+        for field in supported_fields:
29
+            a[field] = field
30
+
31
+        not_supported_fields = ['some', 'random', 'fields']
32
+        for field in not_supported_fields:
33
+            with self.assertRaises(KeyError):
34
+                a[field] = field
35
+
36
+if __name__ == '__main__':
37
+    unittest.main()

+ 202
- 0
sitemap/test/generator/test_pipelines.py Dosyayı Görüntüle

@@ -0,0 +1,202 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import mock
14
+from sitemap.generator import pipelines
15
+import unittest
16
+
17
+
18
+class TestSitemapItemExporter(unittest.TestCase):
19
+
20
+    def test_start_exporting(self):
21
+        output = mock.MagicMock()
22
+        itemExplorer = pipelines.SitemapItemExporter(output)
23
+
24
+        with mock.patch.object(itemExplorer.xg, 'startDocument',
25
+                               return_value=None) as mock_start_document:
26
+            with mock.patch.object(itemExplorer.xg, 'startElement',
27
+                                   return_value=None) as mock_start_element:
28
+                itemExplorer.start_exporting()
29
+
30
+        self.assertTrue(mock_start_document.called)
31
+        self.assertTrue(mock_start_element.called)
32
+
33
+
34
+class TestIgnoreDuplicateUrls(unittest.TestCase):
35
+
36
+    def setUp(self):
37
+        self.ignore_urls = pipelines.IgnoreDuplicateUrls()
38
+
39
+    def test_set_is_set_at_init(self):
40
+        self.assertTrue(isinstance(self.ignore_urls.processed, set))
41
+
42
+    def test_set_is_empty_at_init(self):
43
+        self.assertEqual(len(self.ignore_urls.processed), 0)
44
+
45
+    def test_duplicate_url(self):
46
+        self.ignore_urls.processed.add('url')
47
+        item = {'loc': 'url'}
48
+        spider = mock.MagicMock()
49
+
50
+        with self.assertRaises(pipelines.scrapy.exceptions.DropItem):
51
+            self.ignore_urls.process_item(item, spider)
52
+
53
+    def test_url_added_to_processed(self):
54
+        self.assertFalse('url' in self.ignore_urls.processed)
55
+
56
+        item = {'loc': 'url'}
57
+        spider = mock.MagicMock()
58
+        self.ignore_urls.process_item(item, spider)
59
+        self.assertTrue('url' in self.ignore_urls.processed)
60
+
61
+    def test_item_is_returned(self):
62
+        item = {'loc': 'url'}
63
+        spider = mock.MagicMock()
64
+        returned_item = self.ignore_urls.process_item(item, spider)
65
+        self.assertEqual(item, returned_item)
66
+
67
+
68
+class TestExportSitemap(unittest.TestCase):
69
+
70
+    def setUp(self):
71
+        self.export_sitemap = pipelines.ExportSitemap()
72
+        self.spider = mock.MagicMock()
73
+
74
+    def test_variables_set_at_init(self):
75
+        self.assertTrue(isinstance(self.export_sitemap.files, dict))
76
+        self.assertTrue(self.export_sitemap.exporter is None)
77
+
78
+    def test_spider_opened_calls_open(self):
79
+        with mock.patch.object(pipelines, 'open',
80
+                               return_value=None) as mocked_open:
81
+            with mock.patch.object(pipelines,
82
+                                   'SitemapItemExporter'):
83
+                self.export_sitemap.spider_opened(self.spider)
84
+
85
+        self.assertTrue(mocked_open.called)
86
+
87
+    def test_spider_opened_assigns_spider(self):
88
+        prev_len = len(self.export_sitemap.files)
89
+        with mock.patch.object(pipelines, 'open',
90
+                               return_value=None):
91
+            with mock.patch.object(pipelines,
92
+                                   'SitemapItemExporter'):
93
+                self.export_sitemap.spider_opened(self.spider)
94
+
95
+        after_len = len(self.export_sitemap.files)
96
+        self.assertTrue(after_len - prev_len, 1)
97
+
98
+    def test_spider_opened_instantiates_exporter(self):
99
+        with mock.patch.object(pipelines, 'open',
100
+                               return_value=None):
101
+            with mock.patch.object(pipelines,
102
+                                   'SitemapItemExporter') as mocked_exporter:
103
+                self.export_sitemap.spider_opened(self.spider)
104
+
105
+        self.assertTrue(mocked_exporter.called)
106
+
107
+    def test_spider_opened_exporter_starts_exporting(self):
108
+        with mock.patch.object(pipelines, 'open',
109
+                               return_value=None):
110
+            with mock.patch.object(pipelines.SitemapItemExporter,
111
+                                   'start_exporting') as mocked_start:
112
+                self.export_sitemap.spider_opened(self.spider)
113
+
114
+        self.assertTrue(mocked_start.called)
115
+
116
+    def test_spider_closed_calls_finish(self):
117
+        self.export_sitemap.exporter = mock.MagicMock()
118
+        self.export_sitemap.exporter.finish_exporting = mock.MagicMock()
119
+        self.export_sitemap.files[self.spider] = mock.MagicMock()
120
+
121
+        with mock.patch.object(pipelines, 'lxml'):
122
+            with mock.patch.object(pipelines, 'open'):
123
+                self.export_sitemap.spider_closed(self.spider)
124
+
125
+        self.assertTrue(self.export_sitemap.exporter.finish_exporting.called)
126
+
127
+    def test_spider_closed_pops_spider(self):
128
+        self.export_sitemap.exporter = mock.MagicMock()
129
+        self.export_sitemap.files[self.spider] = mock.MagicMock()
130
+
131
+        self.assertTrue(self.spider in self.export_sitemap.files)
132
+
133
+        with mock.patch.object(pipelines, 'lxml'):
134
+            with mock.patch.object(pipelines, 'open'):
135
+                self.export_sitemap.spider_closed(self.spider)
136
+
137
+        self.assertFalse(self.spider in self.export_sitemap.files)
138
+
139
+    def test_spider_closed_parses_with_lxml(self):
140
+        self.export_sitemap.exporter = mock.MagicMock()
141
+        self.export_sitemap.exporter.finish_exporting = mock.MagicMock()
142
+        self.export_sitemap.files[self.spider] = mock.MagicMock()
143
+
144
+        with mock.patch.object(pipelines.lxml, 'etree'):
145
+            with mock.patch.object(pipelines.lxml.etree,
146
+                                   'parse') as mocked_lxml_parse:
147
+                with mock.patch.object(pipelines, 'open'):
148
+                    self.export_sitemap.spider_closed(self.spider)
149
+
150
+        self.assertTrue(mocked_lxml_parse.called)
151
+
152
+    def test_spider_closed_opens_xml_files(self):
153
+        self.export_sitemap.exporter = mock.MagicMock()
154
+        self.export_sitemap.exporter.finish_exporting = mock.MagicMock()
155
+        self.export_sitemap.files[self.spider] = mock.MagicMock()
156
+
157
+        with mock.patch.object(pipelines, 'lxml'):
158
+            with mock.patch.object(pipelines, 'open') as mocked_open:
159
+                self.export_sitemap.spider_closed(self.spider)
160
+
161
+        self.assertTrue(mocked_open.called)
162
+
163
+    def test_spider_closed_writes_tree(self):
164
+        self.export_sitemap.exporter = mock.MagicMock()
165
+        self.export_sitemap.exporter.finish_exporting = mock.MagicMock()
166
+        self.export_sitemap.files[self.spider] = mock.MagicMock()
167
+
168
+        with mock.patch.object(pipelines.lxml, 'etree'):
169
+            with mock.patch.object(pipelines.lxml.etree,
170
+                                   'tostring') as mocked_lxml_tostring:
171
+                with mock.patch.object(pipelines, 'open'):
172
+                    self.export_sitemap.spider_closed(self.spider)
173
+
174
+        self.assertTrue(mocked_lxml_tostring.called)
175
+
176
+    def test_process_item_exports_item(self):
177
+        item = spider = self.export_sitemap.exporter = mock.MagicMock()
178
+        self.export_sitemap.exporter.export_item = mock.MagicMock()
179
+        self.export_sitemap.process_item(item, spider)
180
+
181
+        self.assertTrue(self.export_sitemap.exporter.export_item.called)
182
+
183
+    def test_process_item_returns_item(self):
184
+        spider = self.export_sitemap.exporter = mock.MagicMock()
185
+        item = {'random': 'item'}
186
+        returned_item = self.export_sitemap.process_item(item, spider)
187
+
188
+        self.assertEqual(item, returned_item)
189
+
190
+    def test_from_crawler_exists(self):
191
+        attr_exists = hasattr(pipelines.ExportSitemap, 'from_crawler')
192
+        attr_callable = callable(getattr(pipelines.ExportSitemap,
193
+                                         'from_crawler'))
194
+        self.assertTrue(attr_exists and attr_callable)
195
+
196
+    def test_from_crawler_assigns_pipeline(self):
197
+        crawler = mock.MagicMock()
198
+        pipelines.ExportSitemap.from_crawler(crawler)
199
+        # still thinking how to go about here.
200
+
201
+if __name__ == '__main__':
202
+    unittest.main()

+ 5
- 1
test-requirements.txt Dosyayı Görüntüle

@@ -11,4 +11,8 @@ pylint==1.4.5 # GPLv2
11 11
 
12 12
 reno>=1.8.0 # Apache2
13 13
 oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
14
-sphinx!=1.3b1,<1.3,>=1.2.1 # BSD
14
+
15
+testrepository>=0.0.18 # Apache-2.0/BSD
16
+
17
+# mock object framework
18
+mock>=2.0 # BSD

+ 3
- 1
tox.ini Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 [tox]
2 2
 minversion = 1.6
3
-envlist = py34,py27,pep8
3
+envlist = py27,pep8
4 4
 skipsdist = True
5 5
 
6 6
 [testenv]
@@ -9,6 +9,8 @@ install_command = pip install -U {opts} {packages}
9 9
 setenv =
10 10
    VIRTUAL_ENV={envdir}
11 11
 deps = -r{toxinidir}/test-requirements.txt
12
+       -r{toxinidir}/requirements.txt
13
+commands = python setup.py testr --slowest --testr-args='{posargs}'
12 14
 
13 15
 [testenv:pep8]
14 16
 commands =

Loading…
İptal
Kaydet