def test_xform_is_the_default_namespace(self):
        # while parsing submission we assume that xform element without namespace since being default.
        xform_as_string = open(self.NAME_SPACE, 'r').read()
        default_namespace_definition_format = 'xmlns="http://www.w3.org/2002/xforms"'

        mangrove_service = MangroveService(self.mock_request, xls_parser_response=XlsParserResponse(xform_as_string=xform_as_string))
        mangrove_service.xform = xform_as_string
        updated_xform = mangrove_service.add_form_code(None)

        self.assertTrue(updated_xform.find(default_namespace_definition_format) != -1)
    def test_should_add_form_code_and_bind_element_to_xform(self):
        xform_as_string = open(self.NAME_SPACE, 'r').read()
        expected_form_code = '022-somthing-making-it-unique-in-xml'

        mangrove_service = MangroveService(self.mock_request, xls_parser_response=XlsParserResponse(xform_as_string=xform_as_string))
        mangrove_service.xform = xform_as_string
        updated_xform = mangrove_service \
            .add_form_code('%s' % expected_form_code)

        form_code = self._find_in_instance(updated_xform, 'form_code')
        self.assertEqual(form_code, expected_form_code)