##// END OF EJS Templates
tests: fixed tests for changed repr.
marcink -
r1333:e3750173 default
parent child Browse files
Show More
@@ -24,24 +24,24 b' import random'
24 from rhodecode.model import db
24 from rhodecode.model import db
25
25
26
26
27 @pytest.mark.parametrize("DBModel, id_attr", [
27 @pytest.mark.parametrize("DBModel, klass, id_attr", [
28 (db.ChangesetComment, 'comment_id'),
28 (db.ChangesetComment, 'Comment', 'comment_id'),
29 (db.PullRequest, 'pull_request_id'),
29 (db.PullRequest, db.PullRequest.__name__, 'pull_request_id'),
30 (db.PullRequestVersion, 'pull_request_version_id'),
30 (db.PullRequestVersion, db.PullRequestVersion.__name__, 'pull_request_version_id'),
31 ])
31 ])
32 class TestModelReprImplementation:
32 class TestModelReprImplementation(object):
33
33
34 def test_repr_without_id(self, DBModel, id_attr):
34 def test_repr_without_id(self, DBModel, klass, id_attr):
35 instance = DBModel()
35 instance = DBModel()
36 expected_repr = '<DB:%s at %#x>' % (DBModel.__name__, id(instance))
36 expected_repr = '<DB:%s at %#x>' % (klass, id(instance))
37 assert repr(instance) == expected_repr
37 assert repr(instance) == expected_repr
38
38
39 def test_repr_with_id(self, DBModel, id_attr):
39 def test_repr_with_id(self, DBModel, klass, id_attr):
40 test_id = random.randint(1, 10)
40 test_id = random.randint(1, 10)
41 instance = DBModel()
41 instance = DBModel()
42 setattr(instance, id_attr, test_id)
42 setattr(instance, id_attr, test_id)
43 expected_repr = (
43 expected_repr = (
44 '<DB:%s #%d>' % (DBModel.__name__, test_id))
44 '<DB:%s #%d>' % (klass, test_id))
45 assert repr(instance) == expected_repr
45 assert repr(instance) == expected_repr
46
46
47
47
General Comments 0
You need to be logged in to leave comments. Login now