def test_split_raw_systematic_id_unparsable(self):
     exception_raised = False
     try:
         systematic_string_to_identifier("Hallo Welt")
     except DataError:
         exception_raised = True
     self.assertTrue(exception_raised)
    def test_fetch_signature_for_document_id_I(self):
        '''
        Tests for existing signature
        '''

        signature = self.dao.fetch_signature_for_document_id(1)
        self.assertEqual(signature, systematic_string_to_identifier('1.1.I'))
    def testFetchSystematicEntriesForDocument(self):

        # Setup
        document = Document(25)
        signature = systematic_string_to_identifier("1.2.IV-3")
        identifier1 = SystematicIdentifier("2.3", 5, 6)
        identifier2 = SystematicIdentifier("3.4", 7, 8)
        self.references_dao.fetch_systematik_ids_for_document_id = MagicMock(
            return_value=[identifier1, identifier2])
        self.references_dao.fetch_signature_for_document_id = MagicMock(
            return_value=signature)

        values = {
            signature: SystematicPoint(signature, "signature"),
            identifier1: SystematicPoint(identifier1, "identifier1"),
            identifier2: SystematicPoint(identifier2, "identifier2")
        }

        def side_effect(arg):
            return values[arg]

        self.systematic_dao.get_by_id = MagicMock(side_effect=side_effect)

        # Execution
        result = self.service.fetch_systematic_entries_for_document(document)

        # Assertion
        self.assertEqual(len(result), 3)

        self.assertIn(QualifiedSystematicPoint(values[signature], True),
                      result)
        self.assertIn(QualifiedSystematicPoint(values[identifier1], False),
                      result)
        self.assertIn(QualifiedSystematicPoint(values[identifier2], False),
                      result)
    def test_set_signature_for_document_id_I(self):
        '''
        Tests for existing signature
        '''
        systematic_node = SystematicPoint(SystematicIdentifier("1.2"), "desc")
        self.dao.set_signature_for_document_id(1, systematic_node)

        table = DOCUMENT_TABLE
        query = select([table.c.standort]).where(table.c.laufnr == 1)
        row = self.dao._get_exactly_one_row(query)
        self.assertEqual('1.2', row[table.c.standort])

        signature = self.dao.fetch_signature_for_document_id(1)
        self.assertEqual(signature, systematic_string_to_identifier('1.2'))
 def test_split_raw_systematic_id_empty_value(self):
     systematic_id = systematic_string_to_identifier(None)
     self.assertEqual(systematic_id, None)
 def test_split_raw_systematic_id_trailing_dot(self):
     systematic_id = systematic_string_to_identifier("1.0.1.VII.")
     self.assertEqual(systematic_id, SystematicIdentifier('1.0.1', 7))
    def test_split_raw_systematic_id_missing_roman(self):

        systematic_id = systematic_string_to_identifier("1.0-1")
        self.assertEqual(systematic_id, SystematicIdentifier('1.0', 0, 1))
 def test_split_raw_systematic_id_folder(self):
     systematic_id = systematic_string_to_identifier("1.0.1.VII-3")
     self.assertEqual(systematic_id, SystematicIdentifier('1.0.1', 7, 3))
    def test_split_raw_systematic_id_simple(self):

        systematic_id = systematic_string_to_identifier("1.0.1")
        self.assertEqual(systematic_id, SystematicIdentifier('1.0.1'))