Show More
@@ -24,24 +24,24 b' import random' | |||
|
24 | 24 | from rhodecode.model import db |
|
25 | 25 | |
|
26 | 26 | |
|
27 | @pytest.mark.parametrize("DBModel, id_attr", [ | |
|
28 | (db.ChangesetComment, 'comment_id'), | |
|
29 | (db.PullRequest, 'pull_request_id'), | |
|
30 | (db.PullRequestVersion, 'pull_request_version_id'), | |
|
27 | @pytest.mark.parametrize("DBModel, klass, id_attr", [ | |
|
28 | (db.ChangesetComment, 'Comment', 'comment_id'), | |
|
29 | (db.PullRequest, db.PullRequest.__name__, 'pull_request_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 | 35 | instance = DBModel() |
|
36 |
expected_repr = '<DB:%s at %#x>' % ( |
|
|
36 | expected_repr = '<DB:%s at %#x>' % (klass, id(instance)) | |
|
37 | 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 | 40 | test_id = random.randint(1, 10) |
|
41 | 41 | instance = DBModel() |
|
42 | 42 | setattr(instance, id_attr, test_id) |
|
43 | 43 | expected_repr = ( |
|
44 |
'<DB:%s #%d>' % ( |
|
|
44 | '<DB:%s #%d>' % (klass, test_id)) | |
|
45 | 45 | assert repr(instance) == expected_repr |
|
46 | 46 | |
|
47 | 47 |
General Comments 0
You need to be logged in to leave comments.
Login now