Ejemplo n.º 1
0
    def testPOSTNewUnicodeTagUnderUnicodeNamespace(self):
        """
        There shouldn't be a problem creating a tag under a namespace whose
        name is expressed in non-ascii characters.

        See the following bug:
        https://bugs.edge.launchpad.net/fluiddb/+bug/762779
        """
        # Use the testuser1 root namespace.
        ns = Namespace('testuser1')
        # Create an interestingly named namespace
        quran = u'\ufe8e\ufee0\ufed7\ufead\ufe81'
        quranNS = ns.create_namespace(quran, 'For the purposes of testing')
        # Attempt to create a new tag underneath
        newTag = False
        try:
            # just check it can be created
            sura = u'\ufeb1\ufeed\ufead'
            newTag = quranNS.create_tag(sura, 'This is a test', False)
            expectedPath = u'testuser1/' + quran + '/' + sura
            self.assertEqual(expectedPath, newTag.path)
        finally:
            if newTag:
                newTag.delete()
            quranNS.delete()
Ejemplo n.º 2
0
    def testPOSTNewUnicodeTagUnderUnicodeNamespace(self):
        """
        There shouldn't be a problem creating a tag under a namespace whose
        name is expressed in non-ascii characters.

        See the following bug:
        https://bugs.edge.launchpad.net/fluiddb/+bug/762779
        """
        # Use the testuser1 root namespace.
        ns = Namespace('testuser1')
        # Create an interestingly named namespace
        quran = u'\ufe8e\ufee0\ufed7\ufead\ufe81'
        quranNS = ns.create_namespace(quran, 'For the purposes of testing')
        # Attempt to create a new tag underneath
        newTag = False
        try:
            # just check it can be created
            sura = u'\ufeb1\ufeed\ufead'
            newTag = quranNS.create_tag(sura, 'This is a test', False)
            expectedPath = u'testuser1/' + quran + '/' + sura
            self.assertEqual(expectedPath, newTag.path)
        finally:
            if newTag:
                newTag.delete()
            quranNS.delete()
Ejemplo n.º 3
0
 def test_create_child(self):
     n = Namespace(u'test')
     self.db.add_resp(201, 'application/json', '{"id": "4", "URI": "https')
     child = n.create_namespace(u'test', u'fomtest description')
     self.assertEquals(child.path, u'test/test')
     self.assertEqual(self.last, ('POST', u'/namespaces/test', {
         'name': u'test',
         'description': u'fomtest description'
     }, None, None))
Ejemplo n.º 4
0
 def test_create_child(self):
     n = Namespace(u'test')
     self.db.add_resp(201, 'application/json',
         '{"id": "4", "URI": "https')
     child = n.create_namespace(u'test', u'fomtest description')
     self.assertEquals(child.path, u'test/test')
     self.assertEqual(self.last, (
         'POST',
         u'/namespaces/test',
         {'name': u'test', 'description': u'fomtest description'},
         None,
         None))
Ejemplo n.º 5
0
def generateNamespaceData(username):
    """Generate random namespace, tag and tag value data.

    @param username: The username to connect as.
    """
    rootNamespace = Namespace(username)
    name = 'namespace-%s' % ''.join(choice(ascii_letters)
                                    for i in xrange(randint(8, 12)))
    namespace = rootNamespace.create_namespace(name, 'A child namespace')
    logQueue.put(('CREATE_NAMESPACE path=%s/%s', (username, name)))
    countQueue.put(1)

    for tagName in WORDS:
        tag = namespace.create_tag(tagName, 'A tag', False)
        logQueue.put(('CREATE_TAG path=%s/%s/%s', (username, name, tagName)))
        countQueue.put(1)
        for i in range(randint(2, 20)):
            value = getRandomValue()
            about = 'namespace %s tag %s count %d' % (name, tagName, i)
            obj = Object(uuid4(), about=about)
            obj.set(tag.path, value)
            logQueue.put(('CREATE_TAG_VALUE value=%s tag=%s/%s/%s',
                          (value, username, name, tagName)))
            countQueue.put(1)
Ejemplo n.º 6
0
def generateNamespaceData(username):
    """Generate random namespace, tag and tag value data.

    @param username: The username to connect as.
    """
    rootNamespace = Namespace(username)
    name = 'namespace-%s' % ''.join(
        choice(ascii_letters) for i in xrange(randint(8, 12)))
    namespace = rootNamespace.create_namespace(name, 'A child namespace')
    logQueue.put(('CREATE_NAMESPACE path=%s/%s', (username, name)))
    countQueue.put(1)

    for tagName in WORDS:
        tag = namespace.create_tag(tagName, 'A tag', False)
        logQueue.put(('CREATE_TAG path=%s/%s/%s', (username, name, tagName)))
        countQueue.put(1)
        for i in range(randint(2, 20)):
            value = getRandomValue()
            about = 'namespace %s tag %s count %d' % (name, tagName, i)
            obj = Object(uuid4(), about=about)
            obj.set(tag.path, value)
            logQueue.put(('CREATE_TAG_VALUE value=%s tag=%s/%s/%s',
                          (value, username, name, tagName)))
            countQueue.put(1)
Ejemplo n.º 7
0

from fom.dev import sandbox_fluid
from fom.mapping import Object, Namespace, tag_value, tag_relation

# Use and bind the sandbox (for playing)
fluid = sandbox_fluid()

# let's start by creating a new Namespace for this application and then some
# tags

# Use the test user's namespace
ns = Namespace(u'test')

# create a child namespace for ourselves
ns.create_namespace(u'maptest', u'a test namespace')

# use our child namespace
ns = Namespace(u'test/maptest')

# create some tags
ns.create_tag(u'description', u'description', indexed=False)
ns.create_tag(u'timestamp', u'description', indexed=False)
ns.create_tag(u'username', u'description', indexed=False)


# Now we will define some behaviours mapping to groups of individual tags

class Describable(Object):
    """Mixin to provide describable behaviour
    """
Ejemplo n.º 8
0
from fom.dev import sandbox_fluid
from fom.mapping import Object, Namespace, tag_value, tag_relation

# Use and bind the sandbox (for playing)
fluid = sandbox_fluid()

# let's start by creating a new Namespace for this application and then some
# tags

# Use the test user's namespace
ns = Namespace(u'test')

# create a child namespace for ourselves
ns.create_namespace(u'maptest', u'a test namespace')

# use our child namespace
ns = Namespace(u'test/maptest')

# create some tags
ns.create_tag(u'description', u'description', indexed=False)
ns.create_tag(u'timestamp', u'description', indexed=False)
ns.create_tag(u'username', u'description', indexed=False)

# Now we will define some behaviours mapping to groups of individual tags


class Describable(Object):
    """Mixin to provide describable behaviour
    """
    description = tag_value(u'test/maptest/description')