Exemplo n.º 1
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)
     self.assertEqual(new_page.content, '')
Exemplo n.º 2
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)
     self.assertEqual(new_page.content, '')
Exemplo n.º 3
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.º 4
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.º 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 self.assertRaises(TypeError) as cm:
            Page(**self.kwargs)

        self.assertEqual('Page.title should be a string, not NoneType',
                         str(cm.exception))
Exemplo n.º 6
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.º 7
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.º 8
0
    def setUp(self):
        """setting up the test
        """
        # create a repository
        self.repository_type = Type(
            name="Test Repository Type",
            code='test_repo',
            target_entity_type=Repository
        )

        self.test_repository = Repository(
            name="Test Repository",
            type=self.repository_type,
        )

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

        # project status list
        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
        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)