def to_project(self):
     project = Project()
     project.pid = self.pid
     user_table_model = self.creator
     if user_table_model is not None:
         project.creator = user_table_model.uid
     project.name = self.name
     return project
Exemplo n.º 2
0
    def setUp(self):
        self.storage_task = TaskStorageAdapter(_TEST_DB)
        self.storage_user = UserStorageAdapter(_TEST_DB)
        self.storage_project = ProjectStorageAdapter(_TEST_DB)

        user = User()
        self.storage_user.save_user(user)
        project = Project()
        project.creator = 1
        self.storage_project.save_project(project)
Exemplo n.º 3
0
    def test_save_get_project(self):
        project = Project()
        project.creator = 1
        project.name = 'Test'

        user = User()
        user.login = '******'
        self.user_storage.save_user(user)

        success = self.storage.save_project(project)
        self.assertEqual(success, True)

        projects_in_db = self.storage.get_projects(1)
        self.assertEqual(len(projects_in_db), 1)

        project.pid = 1
        self.assertEqual(project, projects_in_db[0])
    def test_default_project_created_when_new_user_added(self):

        class ProjectStorageAdapterMock():

            _saved_project = None

            def save_project(self, project):
                self.__class__._saved_project = project
                return True

        class UserStorageAdapterMock():

            _saved_user = None

            def save_user(self, user):
                self.__class__._saved_user = user
                self.__class__._saved_user.uid = 1
                return True

            def check_user_existence(self, login):
                return False

            def get_last_saved_user(self):
                return self._saved_user

        Controller.init_storage_adapters(user_storage_adapter=UserStorageAdapterMock,
                              project_storage_adapter=ProjectStorageAdapterMock)

        user = User()
        user.login = '******'
        self.user_controller.save_user(user)

        project = Project()
        project.creator = 1
        project.name = Project.default_project_name
        self.assertEqual(project, ProjectStorageAdapterMock._saved_project)
Exemplo n.º 5
0
    def test_save_remove_get_project(self):
        project1 = Project()
        project1.creator = 1
        project1.name = 'Test 1'

        project2 = Project()
        project2.creator = 1
        project2.name = 'Test 2'

        user = User()
        user.login = '******'
        self.user_storage.save_user(user)

        self.storage.save_project(project1)
        self.storage.save_project(project2)

        success = self.storage.remove_project(2)
        self.assertEqual(success, True)

        projects_in_db = self.storage.get_projects(1)
        self.assertEqual(len(projects_in_db), 1)

        project1.pid = 1
        self.assertEqual(project1, projects_in_db[0])
Exemplo n.º 6
0
    def test_save_edit_get_project(self):
        project = Project()
        project.creator = 1
        project.name = 'Test'

        user = User()
        user.login = '******'
        self.user_storage.save_user(user)

        self.storage.save_project(project)

        project_fields = {Project.Field.pid: 1, Project.Field.name: 'New test'}
        success = self.storage.edit_project(project_fields)
        self.assertEqual(success, True)

        projects_in_db = self.storage.get_projects(1)
        self.assertEqual(len(projects_in_db), 1)

        project.pid = 1
        project.name = 'New test'
        self.assertEqual(project, projects_in_db[0])
Exemplo n.º 7
0
 def get_projects(self, uid, name=None, pid=None):
     project = Project()
     project.creator = 1
     project.name = Project.default_project_name
     return [project]