def test_no_input_file(self): d = processwwwindex.processwwwindex({}) def check(ret): self.assertEqual(ret, 1) d.addCallback(check) return d
def test_invalid_input_file(self): d = processwwwindex.processwwwindex({'index-file': '/some/no/where'}) def check(ret): self.assertEqual(ret, 2) d.addCallback(check) return d
def test_output_config(self): # Get temporary file ending with ".html" that has visible to other # operations name. with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as tmpf: tmpf_name = tmpf.name with open(tmpf_name, 'w') as f: f.write('{{ configjson|safe }}') ret = yield processwwwindex.processwwwindex({'index-file': tmpf_name}) self.assertEqual(ret, 0) with open(tmpf_name) as f: config = json.loads(f.read()) self.assertTrue(isinstance(config, dict))
def test_output_config(self): tmpf = tempfile.NamedTemporaryFile(suffix=".html") with open(tmpf.name, 'w') as f: f.write('{{ configjson|safe }}') d = processwwwindex.processwwwindex({'index-file': tmpf.name}) def check(ret): self.assertEqual(ret, 0) with open(tmpf.name) as f: config = json.loads(f.read()) self.assertTrue(isinstance(config, dict)) d.addCallback(check) return d
def test_output_config(self): # Get temporary file ending with ".html" that has visible to other # operations name. with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as tmpf: tmpf_name = tmpf.name with open(tmpf_name, "w") as f: f.write("{{ configjson|safe }}") d = processwwwindex.processwwwindex({"index-file": tmpf_name}) def check(ret): self.assertEqual(ret, 0) with open(tmpf_name) as f: config = json.loads(f.read()) self.assertTrue(isinstance(config, dict)) d.addCallback(check) return d
def test_output_config(self): # Get temporary file ending with ".html" that has visible to other # operations name. with tempfile.TemporaryDirectory(suffix='output_config') as src_dir: dst_dir = os.path.join(src_dir, 'output_dir') src_html_path = os.path.join(src_dir, 'index.html') dst_html_path = os.path.join(dst_dir, 'index.html') with open(src_html_path, 'w') as f: f.write('{{ configjson|safe }}') ret = yield processwwwindex.processwwwindex({'src-dir': src_dir, 'dst-dir': dst_dir}) self.assertEqual(ret, 0) with open(dst_html_path) as f: config = json.loads(f.read()) self.assertTrue(isinstance(config, dict))
def test_invalid_input_file(self): ret = yield processwwwindex.processwwwindex( {'index-file': '/some/no/where'}) self.assertEqual(ret, 2)
def test_invalid_input_file(self): ret = yield processwwwindex.processwwwindex({'index-file': '/some/no/where'}) self.assertEqual(ret, 2)
def test_invalid_input_dir(self): ret = yield processwwwindex.processwwwindex({'src-dir': '/some/no/where', 'dst-dir': '/some/no/where'}) self.assertEqual(ret, 2)
def test_no_dst_dir(self): ret = yield processwwwindex.processwwwindex({'str-dir': '/some/no/where'}) self.assertEqual(ret, 1)
def test_no_src_dir(self): ret = yield processwwwindex.processwwwindex({}) self.assertEqual(ret, 1)
def test_no_input_file(self): ret = yield processwwwindex.processwwwindex({}) self.assertEqual(ret, 1)