def test_get_summary_private_registration_should_include_is_registration(self): user = UserFactory() # non-contributor cannot see private registration of public project node = ProjectFactory(public=True) reg = RegistrationFactory(project=node, user=node.creator) res = _get_summary(reg, auth=Auth(user), rescale_ratio=None) # serialized result should have is_registration assert_true(res['summary']['is_registration'])
def test_get_summary_private_registration_should_include_is_registration(self): user = UserFactory() # non-contributor cannot see private registration of public project node = ProjectFactory(is_public=True) reg = RegistrationFactory(project=node, user=node.creator) res = _get_summary(reg, auth=Auth(user), rescale_ratio=None) # serialized result should have is_registration assert_true(res['summary']['is_registration'])
def test_get_summary_private_fork_should_include_is_fork(self): user = UserFactory() # non-contributor cannot see private fork of public project node = ProjectFactory(is_public=True) consolidated_auth = Auth(user=node.creator) fork = node.fork_node(consolidated_auth) res = _get_summary(fork, auth=Auth(user), primary=True, link_id=None) # serialized result should have is_fork assert_true(res['summary']['is_fork'])
def test_get_summary_private_fork_should_include_is_fork(self): user = UserFactory() # non-contributor cannot see private fork of public project node = ProjectFactory(is_public=True) consolidated_auth = Auth(user=node.creator) fork = node.fork_node(consolidated_auth) res = _get_summary(fork, auth=Auth(user), primary=True, link_id=None) # serialized result should have is_fork assert_true(res["summary"]["is_fork"])
def test_get_summary_private_node_should_include_id_and_primary_boolean_reg_and_fork(self): user = UserFactory() # user cannot see this node node = ProjectFactory(is_public=False) result = _get_summary(node, auth=Auth(user), primary=True, link_id=None) # serialized result should have id and primary assert_equal(result["summary"]["id"], node._primary_key) assert_true(result["summary"]["primary"], True) assert_equal(result["summary"]["is_registration"], node.is_registration) assert_equal(result["summary"]["is_fork"], node.is_fork)
def test_get_summary_private_fork_private_project_should_include_is_fork(self): # contributor on a private project user = UserFactory() node = ProjectFactory(is_public=False) node.add_contributor(user) # contributor cannot see private fork of this project consolidated_auth = Auth(user=node.creator) fork = node.fork_node(consolidated_auth) res = _get_summary(fork, auth=Auth(user), primary=True, link_id=None) # serialized result should have is_fork assert_false(res["summary"]["can_view"]) assert_true(res["summary"]["is_fork"])
def test_get_summary_private_fork_private_project_should_include_is_fork( self): # contributor on a private project user = UserFactory() node = ProjectFactory(is_public=False) node.add_contributor(user) # contributor cannot see private fork of this project consolidated_auth = Auth(user=node.creator) fork = node.fork_node(consolidated_auth) res = _get_summary(fork, auth=Auth(user), primary=True, link_id=None) # serialized result should have is_fork assert_false(res['summary']['can_view']) assert_true(res['summary']['is_fork'])
def test_get_summary_private_node_should_include_id_and_primary_boolean_reg_and_fork( self): user = UserFactory() # user cannot see this node node = ProjectFactory(is_public=False) result = _get_summary(node, auth=Auth(user), primary=True, link_id=None) # serialized result should have id and primary assert_equal(result['summary']['id'], node._primary_key) assert_true(result['summary']['primary'], True) assert_equal(result['summary']['is_registration'], node.is_registration) assert_equal(result['summary']['is_fork'], node.is_fork)
def test_get_summary_for_registration_uses_correct_date_format(self): reg = RegistrationFactory() res = _get_summary(reg, auth=Auth(reg.creator)) assert_equal(res['summary']['registered_date'], reg.registered_date.strftime('%Y-%m-%d %H:%M UTC'))
def test_get_summary_for_registration_uses_correct_date_format(self): reg = RegistrationFactory() res = _get_summary(reg, auth=Auth(reg.creator), rescale_ratio=None) assert_equal(res['summary']['registered_date'], reg.registered_date.strftime('%Y-%m-%d %H:%M UTC'))
def test_get_summary_for_registration_uses_correct_date_format(self): reg = RegistrationFactory() res = _get_summary(reg, auth=Auth(reg.creator)) assert_equal(res["summary"]["registered_date"], reg.registered_date.strftime("%Y-%m-%d %H:%M UTC"))