コード例 #1
0
 def test_validate_title_length(self):
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     # Min
     data = TaskFactory.stub(title='x').__dict__
     instance, errors = serializer.load(data)
     assert 'title' in errors
     # Max
     data = TaskFactory.stub(title='x' * 101).__dict__
     instance, errors = serializer.load(data)
     assert 'title' in errors
コード例 #2
0
ファイル: test_serializers.py プロジェクト: xuhcc/airy
 def test_validate_title_length(self):
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     # Min
     data = TaskFactory.stub(title='x').__dict__
     instance, errors = serializer.load(data)
     assert 'title' in errors
     # Max
     data = TaskFactory.stub(title='x' * 101).__dict__
     instance, errors = serializer.load(data)
     assert 'title' in errors
コード例 #3
0
ファイル: test_serializers.py プロジェクト: xuhcc/airy
 def test_validate_project_id(self):
     data = TaskFactory.stub(project=None).__dict__
     data['project_id'] = 0
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     instance, errors = serializer.load(data)
     assert 'project_id' in errors
コード例 #4
0
 def test_validate_project_id(self):
     data = TaskFactory.stub(project=None).__dict__
     data['project_id'] = 0
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     instance, errors = serializer.load(data)
     assert 'project_id' in errors
コード例 #5
0
ファイル: test_serializers.py プロジェクト: xuhcc/airy
 def test_preprocess_url(self):
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     project = ProjectFactory.create()
     self.db.session.commit()
     data = TaskFactory.stub(project=None, url='').__dict__
     data['project_id'] = project.id
     instance, errors = serializer.load(data)
     assert not errors
     assert instance.url is None
コード例 #6
0
 def test_preprocess_url(self):
     serializer = TaskSerializer(
         only=['id', 'title', 'description', 'project_id'])
     project = ProjectFactory.create()
     self.db.session.commit()
     data = TaskFactory.stub(project=None, url='').__dict__
     data['project_id'] = project.id
     instance, errors = serializer.load(data)
     assert not errors
     assert instance.url is None
コード例 #7
0
ファイル: test_serializers.py プロジェクト: xuhcc/airy
 def test_update(self):
     task = TaskFactory.create()
     self.db.session.commit()
     data = TaskFactory.stub(project=None).__dict__
     data['id'] = task.id
     data['project_id'] = task.project.id
     serializer = TaskSerializer(
         only=['id', 'title', 'url', 'description', 'project_id'])
     instance, errors = serializer.load(data)
     assert not errors
     assert instance.id == task.id
     assert instance.title == data['title']
     assert instance.project_id == task.project.id
コード例 #8
0
 def test_update(self):
     task = TaskFactory.create()
     self.db.session.commit()
     data = TaskFactory.stub(project=None).__dict__
     data['id'] = task.id
     data['project_id'] = task.project.id
     serializer = TaskSerializer(
         only=['id', 'title', 'url', 'description', 'project_id'])
     instance, errors = serializer.load(data)
     assert not errors
     assert instance.id == task.id
     assert instance.title == data['title']
     assert instance.project_id == task.project.id