def test_dump_submission_method_names(self):
        """websubmitadmin - test dumping submissions with --method=NAMES"""
        insert_submission_dump(self.dummy_submission_dump_1)
        dumped_submission = dump_submission("DUMMY1", 'NAMES', True)

        self.assert_(dumped_submission.startswith('-- DUMMY1 dump '))

        # Submission will contain date/timestamps that we don't want to consider
        dumped_submission = '\n'.join(dumped_submission.splitlines()[1:])

        expected_dump = """-- Extra:NAMES (the following dump contains rows in sbmALLFUNCDESCR, sbmFUNDESC, sbmFIELD and sbmFIELDDESC tables which are not specific to this submission, but that include keyword DUMMY1)
""" + self.dummy_submission_dump_1

        self.assertEqual(dumped_submission, expected_dump)

        # Dump without delete statements
        dumped_submission = dump_submission("DUMMY1", 'NAMES', False)
        self.assert_("DELETE" not in dumped_submission.upper())

        # Dump without "IGNORE" for duplicate insertions
        dumped_submission = dump_submission("DUMMY1", 'NAMES', False, True)
        self.assert_("IGNORE" in dumped_submission.upper())

        # Test dumping demo submission
        dumped_submission = dump_submission("DEMOART", 'NAMES', True)
        self.assert_(dumped_submission.startswith('-- DEMOART dump '))
    def test_dump_submission_method_relations(self):
        """websubmitadmin - test dumping submissions with --method=RELATIONS"""
        insert_submission_dump(self.dummy_submission_dump_1)
        dumped_submission = dump_submission("DUMMY1", 'RELATIONS', True)

        self.assert_(dumped_submission.startswith('-- DUMMY1 dump '))

        # Submission will contain date/timestamps that we don't want to consider
        dumped_submission = '\n'.join(dumped_submission.splitlines()[1:])

        self.assert_(dumped_submission.startswith("-- Extra:RELATIONS (the following dump contains rows in sbmALLFUNCDESCR, sbmFUNDESC, sbmFIELD and sbmFIELDDESC tables that are not specific to doctype DUMMY1"))
    def test_diff_submission(self):
        """websubmitadmin - test diffing submissions """
        insert_submission_dump(self.dummy_submission_dump_1)
        dumped_submission = dump_submission("DUMMY1", 'NAMES', True)

        dummy_submission_dump_1_and_header = '-- Extra:NAMES (the following dump contains rows in sbmALLFUNCDESCR, sbmFUNDESC, sbmFIELD and sbmFIELDDESC tables which are not specific to this submission, but that include keyword DUMMY1)' + \
                                             self.dummy_submission_dump_1
        diffed_submission = diff_submission(dumped_submission, dummy_submission_dump_1_and_header, verbose=2,
                                            ignore_dates=False, ignore_positions=False, ignore_pages=False)
        # Only the header should differ
        self.assertEqual('\n'.join(diffed_submission.splitlines()[1:]), "")