22
33import entities .templatetags .entities as entity_tags
44from core import recipes
5+ from repocache .populate import populate_entity_cache
56
67
78def test_human_readable_bytes ():
@@ -34,7 +35,7 @@ def test_file_type():
3435@pytest .mark .django_db
3536def test_model_urls (model_with_version ):
3637 model = model_with_version
37- model_version = model .repo . latest_commit
38+ model_version = model .repocache . latest_version
3839 context = {'current_namespace' : 'entities' }
3940
4041 assert entity_tags .ns_url (context , 'new' , 'model' ) == '/entities/models/new'
@@ -64,7 +65,7 @@ def test_model_urls(model_with_version):
6465@pytest .mark .django_db
6566def test_protocol_urls (protocol_with_version ):
6667 protocol = protocol_with_version
67- protocol_version = protocol .repo . latest_commit
68+ protocol_version = protocol .repocache . latest_version
6869 context = {'current_namespace' : 'entities' }
6970
7071 assert entity_tags .ns_url (context , 'new' , 'protocol' ) == '/entities/protocols/new'
@@ -98,6 +99,8 @@ def test_protocol_urls(protocol_with_version):
9899def test_name_of_entity_linked_to_experiment (model_with_version , protocol_with_version ):
99100 model_with_version .repo .tag ('v1' )
100101 protocol_with_version .repo .tag ('v2' )
102+ populate_entity_cache (model_with_version )
103+ populate_entity_cache (protocol_with_version )
101104
102105 exp = recipes .experiment_version .make (
103106 status = 'SUCCESS' ,
@@ -114,29 +117,39 @@ def test_name_of_entity_linked_to_experiment(model_with_version, protocol_with_v
114117@pytest .mark .django_db
115118def test_url_friendly_label (model_with_version , helpers ):
116119 commit = model_with_version .repo .latest_commit
117- assert entity_tags ._url_friendly_label (model_with_version , commit ) == commit .sha
120+ version = model_with_version .repocache .get_version (commit .sha )
121+
122+ assert entity_tags ._url_friendly_label (model_with_version , version ) == commit .sha
118123
119124 model_with_version .repo .tag ('v1' )
120- assert entity_tags ._url_friendly_label (model_with_version , commit ) == 'v1'
125+ populate_entity_cache (model_with_version )
126+
127+ assert entity_tags ._url_friendly_label (model_with_version , version ) == 'v1'
121128
122129 commit2 = helpers .add_version (model_with_version )
123130 model_with_version .repo .tag ('new' )
124- assert entity_tags ._url_friendly_label (model_with_version , commit2 ) == commit2 .sha
131+ populate_entity_cache (model_with_version )
132+ version2 = model_with_version .repocache .get_version (commit2 .sha )
133+
134+ assert entity_tags ._url_friendly_label (model_with_version , version2 ) == commit2 .sha
125135
126136 commit3 = helpers .add_version (model_with_version )
127137 model_with_version .repo .tag ('latest' )
128- assert entity_tags ._url_friendly_label (model_with_version , commit3 ) == commit3 .sha
138+ populate_entity_cache (model_with_version )
139+ version3 = model_with_version .repocache .get_version (commit3 .sha )
140+
141+ assert entity_tags ._url_friendly_label (model_with_version , version3 ) == commit3 .sha
129142
130143
131144@pytest .mark .django_db
132145def test_url_runexperiments (model_with_version , protocol_with_version ):
133146 model = model_with_version
134- model_commit = model .repo . latest_commit
147+ model_commit = model .repocache . latest_version
135148 assert (entity_tags .url_run_experiments (model , model_commit ) ==
136149 '/entities/models/%d/versions/%s/runexperiments' % (model .pk , model_commit .sha ))
137150
138151 protocol = protocol_with_version
139- protocol_commit = protocol .repo . latest_commit
152+ protocol_commit = protocol .repocache . latest_version
140153 assert (entity_tags .url_run_experiments (protocol , protocol_commit ) ==
141154 '/entities/protocols/%d/versions/%s/runexperiments' % (protocol .pk , protocol_commit .sha ))
142155
0 commit comments