Ejemplo n.º 1
0
    def test_no_encoding_declaration(self):
        """
        Check that the xml sting is left intact when no encoding declaration is made
        """
        # GIVEN: A reset mocked out re and an instance of foil_presenter
        self.mocked_re.reset()
        foil_presenter_instance = FoilPresenter(self.mocked_manager, self.mocked_song_import)

        # WHEN: xml_to_song is called with a string without an xml encoding declaration
        foil_presenter_instance.xml_to_song('<foilpresenterfolie>')

        # THEN: the string should have been left intact
        self.mocked_re.compile.sub.called_with('<foilpresenterfolie>')
Ejemplo n.º 2
0
    def test_encoding_declaration_removal(self):
        """
        Test that the encoding declaration is removed
        """
        # GIVEN: A reset mocked out re and an instance of foil_presenter
        self.mocked_re.reset()
        foil_presenter_instance = FoilPresenter(self.mocked_manager, self.mocked_song_import)

        # WHEN: xml_to_song is called with a string with an xml encoding declaration
        foil_presenter_instance.xml_to_song('<?xml version="1.0" encoding="UTF-8"?>\n<foilpresenterfolie>')

        # THEN: the xml encoding declaration should have been stripped
        self.mocked_re.compile.sub.called_with('\n<foilpresenterfolie>')
    def no_encoding_declaration_test(self):
        """
        Check that the xml sting is left intact when no encoding declaration is made
        """
        # GIVEN: A reset mocked out re and an instance of foil_presenter
        self.mocked_re.reset()
        foil_presenter_instance = FoilPresenter(self.mocked_manager, self.mocked_song_import)

        # WHEN: xml_to_song is called with a string without an xml encoding declaration
        foil_presenter_instance.xml_to_song('<foilpresenterfolie>')

        # THEN: the string should have been left intact
        self.mocked_re.compile.sub.called_with('<foilpresenterfolie>')
    def encoding_declaration_removal_test(self):
        """
        Test that the encoding declaration is removed
        """
        # GIVEN: A reset mocked out re and an instance of foil_presenter
        self.mocked_re.reset()
        foil_presenter_instance = FoilPresenter(self.mocked_manager, self.mocked_song_import)

        # WHEN: xml_to_song is called with a string with an xml encoding declaration
        foil_presenter_instance.xml_to_song('<?xml version="1.0" encoding="UTF-8"?>\n<foilpresenterfolie>')

        # THEN: the xml encoding declaration should have been stripped
        self.mocked_re.compile.sub.called_with('\n<foilpresenterfolie>')
Ejemplo n.º 5
0
    def test_no_xml(self):
        """
        Test calling xml_to_song with out the xml argument
        """
        # GIVEN: A mocked out "manager" and "SongImport" as well as an foil_presenter instance
        mocked_manager = MagicMock()
        mocked_song_import = MagicMock()
        foil_presenter_instance = FoilPresenter(mocked_manager, mocked_song_import)

        # WHEN: xml_to_song is called without valid an argument
        for arg in [None, False, 0, '']:
            result = foil_presenter_instance.xml_to_song(arg)

            # Then: xml_to_song should return False
            assert result is None, 'xml_to_song should return None when called with %s' % arg
    def no_xml_test(self):
        """
        Test calling xml_to_song with out the xml argument
        """
        # GIVEN: A mocked out "manager" and "SongImport" as well as an foil_presenter instance
        mocked_manager = MagicMock()
        mocked_song_import = MagicMock()
        foil_presenter_instance = FoilPresenter(mocked_manager, mocked_song_import)

        # WHEN: xml_to_song is called without valid an argument
        for arg in [None, False, 0, '']:
            result = foil_presenter_instance.xml_to_song(arg)

            # Then: xml_to_song should return False
            self.assertEqual(result, None, 'xml_to_song should return None when called with %s' % arg)