Beispiel #1
0
    def test_equality(self):
        """testing the equality of two simple entities
        """
        # create two simple entities with same parameters and check for
        # equality
        se1 = SimpleEntity(**self.kwargs)
        se2 = SimpleEntity(**self.kwargs)

        self.kwargs["name"] = "a different simple entity"
        self.kwargs["description"] = "no description"
        se3 = SimpleEntity(**self.kwargs)
        self.assertTrue(se1 == se2)
        self.assertFalse(se1 == se3)
Beispiel #2
0
 def test_html_class_argument_is_None(self):
     """testing if the html_class argument is set to None the html_class
     attribute will be an empty string
     """
     self.kwargs['html_class'] = None
     se = SimpleEntity(**self.kwargs)
     self.assertEqual(se.html_class, '')
Beispiel #3
0
 def test_name_argument_is_empty_string(self):
     """testing if the name attribute will be set to an automatic value if
     the name argument is an empty string
     """
     self.kwargs["name"] = ""
     new_simple_entity = SimpleEntity(**self.kwargs)
     self.assertTrue(new_simple_entity.name)
Beispiel #4
0
 def test_name_argument_is_None(self):
     """testing if the name attribute will be automatically generated if the
     name argument is None
     """
     self.kwargs["name"] = None
     new_simple_entity = SimpleEntity(**self.kwargs)
     self.assertTrue(new_simple_entity.name)
Beispiel #5
0
    def test_generic_text_argument_None(self):
        """testing if generic_text property will be converted to an empty
        string if None is given as the generic_text argument
        """
        self.kwargs["generic_text"] = None
        new_simple_entity = SimpleEntity(**self.kwargs)

        self.assertEqual(new_simple_entity.generic_text, "")
Beispiel #6
0
    def test_description_argument_None(self):
        """testing if description property will be converted to an empty string
        if None is given as the description argument
        """
        self.kwargs["description"] = None
        new_simple_entity = SimpleEntity(**self.kwargs)

        self.assertEqual(new_simple_entity.description, "")
Beispiel #7
0
 def test_html_class_argument_is_working_properly(self):
     """testing if the html_class argument value is correctly passed to the
     html_class attribute
     """
     test_value = 'purple'
     self.kwargs['html_class'] = test_value
     se = SimpleEntity(**self.kwargs)
     self.assertEqual(se.html_class, test_value)
Beispiel #8
0
 def test_html_style_argument_is_working_properly(self):
     """testing if the html_style argument value is correctly passed to the
     html_style attribute
     """
     test_value = 'width: 100px; color: purple; background-color: black'
     self.kwargs['html_style'] = test_value
     se = SimpleEntity(**self.kwargs)
     self.assertEqual(se.html_style, test_value)
Beispiel #9
0
 def test_html_class_argument_is_skipped(self):
     """testing if the html_class argument is skipped the html_class
     attribute will be an empty string
     """
     if 'html_class' in self.kwargs:
         self.kwargs.pop('html_class')
     se = SimpleEntity(**self.kwargs)
     self.assertEqual(se.html_class, '')
Beispiel #10
0
 def test_type_argument_accepts_Type_instances(self):
     """testing if no error will be raised when the type argument is given
     as a stalker.models.type.Type instance
     """
     # test with a proper Type
     self.kwargs["type"] = self.test_type
     # no error is expected
     new_simple_entity = SimpleEntity(**self.kwargs)
     self.assertTrue(isinstance(new_simple_entity, SimpleEntity))
Beispiel #11
0
    def test_thumbnail_argument_is_working_properly(self):
        """testing if the thumbnail argument value is passed to the thumbnail
        attribute correctly
        """
        from stalker import Link

        thumb = Link(full_path='some path')
        self.kwargs['thumbnail'] = thumb
        new_simple_entity = SimpleEntity(**self.kwargs)
        self.assertEqual(new_simple_entity.thumbnail, thumb)
Beispiel #12
0
    def test_thumbnail_argument_is_skipped(self):
        """testing if the thumbnail attribute will be None when the thumbnail
        argument is skipped
        """
        try:
            self.kwargs.pop('thumbnail')
        except KeyError:
            pass

        new_simple_entity = SimpleEntity(**self.kwargs)
        self.assertTrue(new_simple_entity.thumbnail is None)
Beispiel #13
0
    def test_updated_by_argument_empty(self):
        """testing if initializing updated_by with None causes it to be set to
        the same value with created_by argument
        """
        self.kwargs["updated_by"] = None

        new_simple_entity = SimpleEntity(**self.kwargs)

        # now check if they are same
        self.assertEqual(new_simple_entity.created_by,
                         new_simple_entity.updated_by)
Beispiel #14
0
    def test___stalker_version__attribute_is_automatically_set_to_the_current_Stalker_version(self):
        """testing if the __stalker_version__ is automatically set to the
        current version for the newly created SimpleEntities
        """
        new_simple_entity = SimpleEntity(**self.kwargs)
        self.assertEqual(new_simple_entity.__stalker_version__,
                         stalker.__version__)

        # update stalker.__version__ to a test value
        current_version = stalker.__version__

        test_version = "test_version"
        stalker.__version__ = test_version

        # test if it is updated
        self.assertEqual(stalker.__version__, test_version)

        # create a new SimpleEntity and check if it is following the version
        new_simple_entity2 = SimpleEntity(**self.kwargs)
        self.assertEqual(new_simple_entity2.__stalker_version__, test_version)

        # restore the stalker.__version__
        stalker.__version__ = current_version
Beispiel #15
0
    def setUp(self):
        """setting up some proper values
        """
        # create a user
        self.test_user = User(
            name="Test User",
            login="******",
            email="*****@*****.**",
            password="******",
            generic_text=json.dumps(
                {
                    'Phone number': '123'
                },
                sort_keys=True
            ),
        )

        self.date_created = datetime.datetime(2010, 10, 21, 3, 8, 0)
        self.date_updated = self.date_created

        self.kwargs = {
            "name": "Test Entity",
            "code": "TstEnt",
            "description": "This is a test entity, and this is a proper \
            description for it",
            "created_by": self.test_user,
            "updated_by": self.test_user,
            "date_created": self.date_created,
            "date_updated": self.date_updated,
            'generic_text': json.dumps(
                {
                    'Phone number': '123'
                },
                sort_keys=True
            ),
        }

        # create a proper SimpleEntity to use it later in the tests
        self.test_simple_entity = SimpleEntity(**self.kwargs)

        self.test_type = Type(
            name="Test Type",
            code='test',
            target_entity_type=SimpleEntity
        )

        # a couple of test values

        self.name_test_values = [
            ("testName", "testName"),
            ("test-Name", "test-Name"),
            ("1testName", "1testName"),
            ("_testName", "_testName"),
            ("2423$+^^+^'%+%%&_testName", "2423$+^^+^'%+%%&_testName"),
            ("2423$+^^+^'%+%%&_testName_35", "2423$+^^+^'%+%%&_testName_35"),
            ("2423$ +^^+^ '%+%%&_ testName_ 35",
             "2423$ +^^+^ '%+%%&_ testName_ 35"),
            ("SH001", "SH001"),
            ("46-BJ-3A", "46-BJ-3A"),
            ('304-sb-0403-0040', '304-sb-0403-0040'),
            ("Ozgur    Yilmaz\n\n\n", "Ozgur Yilmaz"),
            ("     Ozgur Yilmaz    ", "Ozgur Yilmaz")
        ]

        self.nice_name_test_values = [
            ("testName", "testName"),
            ("1testName", "1testName"),
            ("_testName", "testName"),
            ("2423$+^^+^'%+%%&_testName", "2423_testName"),
            ("2423$+^^+^'%+%%&_testName_35", "2423_testName_35"),
            ("2423$ +^^+^ '%+%%&_ testName_ 35", "2423_testName_35"),
            ("SH001", "SH001"),
            ("My name is Ozgur", "My_name_is_Ozgur"),
            (" this is another name for an asset",
             "this_is_another_name_for_an_asset"),
            ("Ozgur    Yilmaz\n\n\n", "Ozgur_Yilmaz"),
        ]
Beispiel #16
0
 def test_thumbnail_argument_is_None(self):
     """testing if the thumbnail argument can be None
     """
     self.kwargs['thumbnail'] = None
     new_simple_entity = SimpleEntity(**self.kwargs)
     self.assertTrue(new_simple_entity.thumbnail is None)
Beispiel #17
0
    def test_generic_data_attribute_can_hold_a_wide_variety_of_object_types(self):
        """testing if the generic_data attribute can hold any kind of object as
        a list
        """
        from stalker import db

        db.setup()

        new_simple_entity = SimpleEntity(**self.kwargs)
        test_user = User(
            name='email',
            login='******',
            email='*****@*****.**',
            password='******',
        )

        from stalker import Department

        test_department = Department(
            name='department1'
        )

        from stalker import Repository

        test_repo = Repository(
            name='Test Repository'
        )

        from stalker import Structure

        test_struct = Structure(
            name='Test Project Structure'
        )

        from stalker import Status, StatusList

        test_project_status_list = StatusList(
            name='Project Status List',
            target_entity_type='Project',
            statuses=[
                Status(name='Active', code='ACT')
            ]
        )

        from stalker import Project

        test_proj = Project(
            name='Test Project 1',
            code='tp1',
            repository=test_repo,
            structure=test_struct,
            status_list=test_project_status_list
        )

        new_simple_entity.generic_data.extend(
            [test_proj, test_project_status_list, test_struct, test_repo,
             test_department, test_user]
        )

        DBSession.add(new_simple_entity)
        DBSession.commit()

        # now check if it is added to the database correctly
        del new_simple_entity

        new_simple_entity_db = SimpleEntity.query \
            .filter_by(name=self.kwargs['name']) \
            .first()

        self.assertTrue(test_proj in new_simple_entity_db.generic_data)
        self.assertTrue(
            test_project_status_list in new_simple_entity_db.generic_data)
        self.assertTrue(test_struct in new_simple_entity_db.generic_data)
        self.assertTrue(test_repo in new_simple_entity_db.generic_data)
        self.assertTrue(test_department in new_simple_entity_db.generic_data)
        self.assertTrue(test_user in new_simple_entity_db.generic_data)

        DBSession.remove()
Beispiel #18
0
 def test_type_argument_is_None(self):
     """testing if nothing will happen the type argument is None
     """
     self.kwargs["type"] = None
     new_simple_entity = SimpleEntity(**self.kwargs)
     self.assertTrue(isinstance(new_simple_entity, SimpleEntity))