def test_adding_tag(session, company, location): one = Tag(tag=u'one') # Test adding tags via the constructor, hence not using the fixture. job = Job(title=u'foo', description=u'foo', contact_method=1, remote_work=False, company=company, location=location, job_type=1, recruiter_name=u'foo bar', recruiter_email=u'*****@*****.**', tags=[one]) # Try to add one existing and two new tags. tags = job.add_tags([u'one', u'two', u'three']) session.add(job) session.commit() assert len(job.tags) == 3 for tag in tags: assert tag in job.tags