Exemplo n.º 1
0
 def test_content_argument_is_empty_string(self):
     """testing if the content attribute value will be an empty string if
     the content argument is an empty string
     """
     self.kwargs['content'] = ''
     new_page = Page(**self.kwargs)
     assert new_page.content == ''
Exemplo n.º 2
0
 def test_content_argument_is_None(self):
     """testing if the content attribute value will be an empty string if
     the content argument is None
     """
     self.kwargs['content'] = None
     new_page = Page(**self.kwargs)
     self.assertEqual(new_page.content, '')
Exemplo n.º 3
0
 def test_content_argument_skipped(self):
     """testing if the content attribute value will be an empty string if
     the content argument is skipped
     """
     self.kwargs.pop('content')
     new_page = Page(**self.kwargs)
     assert new_page.content == ''
Exemplo n.º 4
0
    def setUp(self):
        """setting up the test
        """
        super(PageTester, self).setUp()

        # create a repository
        from stalker import Type
        self.repository_type = Type(name="Test Repository Type",
                                    code='test_repo',
                                    target_entity_type='Repository')

        from stalker import Repository
        self.test_repository = Repository(
            name="Test Repository",
            code="TR",
            type=self.repository_type,
        )

        # statuses
        from stalker import Status
        self.status1 = Status(name="Status1", code="STS1")
        self.status2 = Status(name="Status2", code="STS2")
        self.status3 = Status(name="Status3", code="STS3")

        # project status list
        from stalker import StatusList
        self.project_status_list = StatusList(name="Project Status List",
                                              statuses=[
                                                  self.status1,
                                                  self.status2,
                                                  self.status3,
                                              ],
                                              target_entity_type='Project')

        # project type
        self.test_project_type = Type(
            name="Test Project Type",
            code='testproj',
            target_entity_type='Project',
        )

        # create projects
        from stalker import Project
        self.test_project1 = Project(
            name="Test Project 1",
            code='tp1',
            type=self.test_project_type,
            status_list=self.project_status_list,
            repository=self.test_repository,
        )

        self.kwargs = {
            'title': 'Test Page Title',
            'content': 'Test content',
            'project': self.test_project1
        }

        self.test_page = Page(**self.kwargs)
Exemplo n.º 5
0
    def test_title_argument_is_None(self):
        """testing if a TypeError will be raised when the title argument is
        None
        """
        self.kwargs['title'] = None
        with pytest.raises(TypeError) as cm:
            Page(**self.kwargs)

        assert str(cm.value) == 'Page.title should be a string, not NoneType'
Exemplo n.º 6
0
    def test_title_argument_is_skipped(self):
        """testing if a ValueError will be raised when the title argument is
        skipped
        """
        self.kwargs.pop('title')
        with pytest.raises(ValueError) as cm:
            Page(**self.kwargs)

        assert str(cm.value) == 'Page.title can not be empty'
Exemplo n.º 7
0
    def test_content_argument_is_not_a_string(self):
        """testing if a TypeError will be raised when the content argument is
        not a string
        """
        self.kwargs['content'] = 1234
        with pytest.raises(TypeError) as cm:
            Page(**self.kwargs)

        assert str(cm.value) == 'Page.content should be a string, not int'
Exemplo n.º 8
0
    def test_title_argument_is_not_a_string(self):
        """testing if a TypeError will be raised when the title argument is not
        a string
        """
        self.kwargs['title'] = 2165
        with pytest.raises(TypeError) as cm:
            Page(**self.kwargs)

        assert str(cm.value) == 'Page.title should be a string, not int'
Exemplo n.º 9
0
    def test_title_argument_is_an_empty_string(self):
        """testing if a ValueError will be raised when the title argument is
        an empty string
        """
        self.kwargs['title'] = ''
        with pytest.raises(ValueError) as cm:
            Page(**self.kwargs)

        assert str(cm.value) == 'Page.title can not be empty'
Exemplo n.º 10
0
    def test_title_argument_is_skipped(self):
        """testing if a ValueError will be raised when the title argument is
        skipped
        """
        self.kwargs.pop('title')
        with self.assertRaises(ValueError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.title can not be empty', str(cm.exception))
Exemplo n.º 11
0
    def test_title_argument_is_an_empty_string(self):
        """testing if a ValueError will be raised when the title argument is
        an empty string
        """
        self.kwargs['title'] = ''
        with self.assertRaises(ValueError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.title can not be empty', str(cm.exception))
Exemplo n.º 12
0
    def test_content_argument_is_not_a_string(self):
        """testing if a TypeError will be raised when the content argument is
        not a string
        """
        self.kwargs['content'] = 1234
        with self.assertRaises(TypeError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.content should be a string, not int',
                         str(cm.exception))
Exemplo n.º 13
0
    def test_title_argument_is_not_a_string(self):
        """testing if a TypeError will be raised when the title argument is not
        a string
        """
        self.kwargs['title'] = 2165
        with self.assertRaises(TypeError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.title should be a string, not int',
                         str(cm.exception))
Exemplo n.º 14
0
    def test_title_argument_is_None(self):
        """testing if a TypeError will be raised when the title argument is
        None
        """
        self.kwargs['title'] = None
        with self.assertRaises(TypeError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.title should be a string, not NoneType',
                         str(cm.exception))