def test_is_public_node_register_page(self): self.node.is_public = True self.node.save() reg = RegistrationFactory(project=self.node) reg.is_public = True reg.save() url = reg.web_url_for('node_register_page') res = self.app.get(url, auth=None) assert_equal(res.status_code, http.OK)
def test_get_recent_public_registrations(self): count = 0 for i in range(5): reg = RegistrationFactory() reg.is_public = True count = count + 1 tdiff = datetime.datetime.now() - datetime.timedelta(days=count) self.set_registered_date(reg, tdiff) regs = [r for r in project_utils.recent_public_registrations()] assert_equal(len(regs), 5) for i in range(4): assert_true(regs[i].registered_date > regs[i + 1].registered_date) for i in range(5): reg = RegistrationFactory() reg.is_public = True count = count + 1 tdiff = datetime.datetime.now() - datetime.timedelta(days=count) self.set_registered_date(reg, tdiff) regs = [r for r in project_utils.recent_public_registrations(7)] assert_equal(len(regs), 7)
def test_get_node_name(self): user = UserFactory() auth = Auth(user=user) another_user = UserFactory() another_auth = Auth(user=another_user) # Public (Can View) public_project = ProjectFactory(is_public=True) collector = rubeus.NodeFileCollector(node=public_project, auth=another_auth) node_name = u'{0}: {1}'.format( public_project.project_or_component.capitalize(), sanitize.unescape_entities(public_project.title)) assert_equal(collector._get_node_name(public_project), node_name) # Private (Can't View) registration_private = RegistrationFactory(creator=user) registration_private.is_public = False registration_private.save() collector = rubeus.NodeFileCollector(node=registration_private, auth=another_auth) assert_equal(collector._get_node_name(registration_private), u'Private Registration') content = ProjectFactory(creator=user) node = ProjectFactory(creator=user) forked_private = node.fork_node(auth=auth) forked_private.is_public = False forked_private.save() collector = rubeus.NodeFileCollector(node=forked_private, auth=another_auth) assert_equal(collector._get_node_name(forked_private), u'Private Fork') pointer_private = node.add_pointer(content, auth=auth) pointer_private.is_public = False pointer_private.save() collector = rubeus.NodeFileCollector(node=pointer_private, auth=another_auth) assert_equal(collector._get_node_name(pointer_private), u'Private Link') private_project = ProjectFactory(is_public=False) collector = rubeus.NodeFileCollector(node=private_project, auth=another_auth) assert_equal(collector._get_node_name(private_project), u'Private Component') private_node = NodeFactory(is_public=False) collector = rubeus.NodeFileCollector(node=private_node, auth=another_auth) assert_equal(collector._get_node_name(private_node), u'Private Component')
def test_get_node_name(self): user = UserFactory() auth = Auth(user=user) another_user = UserFactory() another_auth = Auth(user=another_user) # Public (Can View) public_project = ProjectFactory(is_public=True) collector = rubeus.NodeFileCollector(node=public_project, auth=another_auth) node_name = u"{0}: {1}".format( public_project.project_or_component.capitalize(), sanitize.unescape_entities(public_project.title) ) assert_equal(collector._get_node_name(public_project), node_name) # Private (Can't View) registration_private = RegistrationFactory(creator=user) registration_private.is_public = False registration_private.save() collector = rubeus.NodeFileCollector(node=registration_private, auth=another_auth) assert_equal(collector._get_node_name(registration_private), u"Private Registration") content = ProjectFactory(creator=user) node = ProjectFactory(creator=user) forked_private = node.fork_node(auth=auth) forked_private.is_public = False forked_private.save() collector = rubeus.NodeFileCollector(node=forked_private, auth=another_auth) assert_equal(collector._get_node_name(forked_private), u"Private Fork") pointer_private = node.add_pointer(content, auth=auth) pointer_private.is_public = False pointer_private.save() collector = rubeus.NodeFileCollector(node=pointer_private, auth=another_auth) assert_equal(collector._get_node_name(pointer_private), u"Private Link") private_project = ProjectFactory(is_public=False) collector = rubeus.NodeFileCollector(node=private_project, auth=another_auth) assert_equal(collector._get_node_name(private_project), u"Private Component") private_node = NodeFactory(is_public=False) collector = rubeus.NodeFileCollector(node=private_node, auth=another_auth) assert_equal(collector._get_node_name(private_node), u"Private Component")