def test_compile_empty(self):
     """A project with no config/proze files generates nothing."""
     args = MockArgs(
         doctype='txt',
         output=OUTPUT_PATH[:-4],
         path=no_data.root_path)
     proze.run(args)
     self.assertFalse(os.path.isfile(OUTPUT_PATH))
 def test_compile_missing(self):
     """A project config file has links to files that don't exist."""
     args = MockArgs(
         doctype='txt',
         output=OUTPUT_PATH[:-4],
         path=missing.root_path)
     proze.run(args)
     with open(OUTPUT_PATH) as f:
         self.assertEqual(f.read(), '')
 def test_compile_options(self):
     """Test loading compile options from config file."""
     args = MockArgs(path=dark_and_stormy)
     options = lib.config.load(args)
     self.assertEqual(options.compile.paragraph.mode, 'prose')
     self.assertFalse(options.compile.paragraph.tabFirst.title)
     self.assertTrue(options.compile.paragraph.tabFirst.chapter)
     self.assertTrue(options.compile.paragraph.tabFirst.section)
     self.assertTrue(options.compile.paragraph.removeBlankLines)
     self.assertEqual(options.compile.spacing, 'single')
 def test_order_from_config(self):
     """Test order of files based on config file."""
     order = [
         'title.proze',
         'erased.proze',
         'disaster.proze',
         'flee.proze',
         'reassurances.proze',
         'awakening.proze',
     ]
     args = MockArgs(path=dark_and_stormy)
     options = lib.config.load(args)
     self.assertEqual(options.compile.order, order)
 def test_pumpkins(self):
     """Compile the pumpkins sample project."""
     args = MockArgs(
         doctype='txt',
         output=OUTPUT_PATH[:-4],
         path=pumpkins.root_path
     )
     proze.run(args)
     generated_lines, expected_lines = self.load_files(
         OUTPUT_PATH,
         pumpkins.expected_output
     )
     self.assertEqual(len(generated_lines), len(expected_lines))
     for i in range(0, len(expected_lines)):
         self.assertEqual(generated_lines[i], expected_lines[i])
 def test_dark_and_stormy(self):
     """Compile the dark-and-stormy sample project."""
     args = MockArgs(
         doctype='txt',
         output=OUTPUT_PATH[:-4],
         path=dark_and_stormy.root_path
     )
     proze.run(args)
     generated_lines, expected_lines = self.load_files(
         OUTPUT_PATH,
         dark_and_stormy.expected_output
     )
     self.assertEqual(len(generated_lines), len(expected_lines))
     for i in range(0, len(expected_lines)):
         self.assertEqual(generated_lines[i], expected_lines[i])
    def test_no_data(self):
        """Test a project path that doesn't have a config nor proze files."""
        args = MockArgs(path=no_data)
        options = lib.config.load(args)
        self.assertEqual(options.compile.order, [])
        self.assertEqual(options.names.characters, [])
        self.assertEqual(options.names.places, [])
        self.assertEqual(options.names.things, [])
        self.assertEqual(options.names.invalid, [])

        # Default compile options should be used.
        self.assertEqual(options.compile.paragraph.mode, 'prose')
        self.assertFalse(options.compile.paragraph.tabFirst.title)
        self.assertFalse(options.compile.paragraph.tabFirst.chapter)
        self.assertFalse(options.compile.paragraph.tabFirst.section)
        self.assertTrue(options.compile.paragraph.removeBlankLines)
        self.assertEqual(options.compile.spacing, 'single')
 def test_order_no_config(self):
     """Test globbing files for the file order if not in the config file."""
     order = [
         'conflict/cruise/bridge.proze',
         'conflict/cruise/cabin.proze',
         'conflict/cruise/deck.proze',
         'conflict/cruise/engine-room.proze',
         'conflict/dinner-party.proze',
         'conflict/forest.proze',
         'conflict/shopping.proze',
         'romance/at-the-lake.proze',
         'romance/blimp.proze',
         'romance/caverns.proze',
         'romance/rainstorm.proze',
         'title.proze',
     ]
     args = MockArgs(path=feelings)
     options = lib.config.load(args)
     self.assertEqual(options.compile.order, order)
 def test_names(self):
     """Test names loaded from config file."""
     characters = [
         'Dallas',
         'Jacob',
         'Kathy Jones',
         'Sally',
         'Winchester Mason',
     ]
     places = ['Happenstance Ridge', 'Tottle Town']
     things = ['cheddar house', 'quick zapper']
     invalid = [
         'cheddar castle',
         'Gerald',
         'Happenstance Plateau',
         'Yates',
     ]
     args = MockArgs(path=dark_and_stormy)
     options = lib.config.load(args)
     self.assertEqual(options.names.characters, characters)
     self.assertEqual(options.names.places, places)
     self.assertEqual(options.names.things, things)
     self.assertEqual(options.names.invalid, invalid)