Exemple #1
0
 def testWritesToSeparateGraph(self):
     g1 = ConjunctiveGraph()
     g2 = ConjunctiveGraph()
     c = CommandLog(Graph2(g1, initNs=INITNS), Graph2(g2, initNs=INITNS))
     c.addCommand(CMD['c1'], dateTime('18:00:00'), USER['drewp'])
     self.assertEqual(len(g1), 0)
     self.assert_(len(g2) > 0)
Exemple #2
0
 def testWritesToSeparateGraph(self):
     g1 = ConjunctiveGraph()
     g2 = ConjunctiveGraph()
     c = CommandLog(Graph2(g1, initNs=INITNS), Graph2(g2, initNs=INITNS))
     c.addCommand(CMD['c1'], dateTime('18:00:00'), USER['drewp'])
     self.assertEqual(len(g1), 0)
     self.assert_(len(g2) > 0)
Exemple #3
0
 def testDoesntSendStrayClasses(self):
     pings = []
     self.graph.add((CMD['other'], RDF.type, CMD['Other']))
     self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                          newCommandPing=lambda **kw: pings.append(kw))
     self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
     self.assertEqual(len(pings), 1)
Exemple #4
0
    def testSendsPing(self):
        pings = []

        self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                             newCommandPing=lambda **kw: pings.append(kw))
        self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
        self.assertEqual(pings, [{
            'content':
            'http://bigasterisk.com/command/http%3A//example.com/c2/1228183200.0/http%3A//example.com/user/drewp',
            'signal': 'http://example.com/Bright'
        }])
Exemple #5
0
 def testDoesntSendStrayClasses(self):
     pings = []
     self.graph.add((CMD['other'], RDF.type, CMD['Other']))
     self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                          newCommandPing=lambda **kw: pings.append(kw))
     self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
     self.assertEqual(len(pings), 1)
Exemple #6
0
 def testSendsPing(self):
     pings = []
     
     self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                          newCommandPing=lambda **kw: pings.append(kw))
     self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
     self.assertEqual(pings, [
         {'content': 'http://bigasterisk.com/command/http%3A//example.com/c2/1228183200.0/http%3A//example.com/user/drewp',
          'signal': 'http://example.com/Bright'}])
Exemple #7
0
    def testSendsMultipleClasses(self):
        pings = []

        self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                             newCommandPing=lambda **kw: pings.append(kw))
        self.graph.add((CMD['c2'], RDF.type, CMD['Volume']))  # second cls

        self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
        c = 'http://bigasterisk.com/command/http%3A//example.com/c2/1228183200.0/http%3A//example.com/user/drewp'
        self.assertEqual(
            sorted(pings),
            sorted([{
                'content': c,
                'signal': 'http://example.com/Bright'
            }, {
                'content': c,
                'signal': 'http://example.com/Volume'
            }]))
Exemple #8
0
    def testSendsMultipleClasses(self):
        pings = []
        
        self.cl = CommandLog(Graph2(self.graph, initNs=INITNS),
                             newCommandPing=lambda **kw: pings.append(kw))
        self.graph.add((CMD['c2'], RDF.type, CMD['Volume'])) # second cls

        self.cl.addCommand(CMD['c2'], dateTime('18:00:00'), USER['drewp'])
        c = 'http://bigasterisk.com/command/http%3A//example.com/c2/1228183200.0/http%3A//example.com/user/drewp'
        self.assertEqual(sorted(pings), sorted([
            {'content': c, 'signal': 'http://example.com/Bright'},
            {'content': c, 'signal': 'http://example.com/Volume'}]))
Exemple #9
0
 def testUsesSingleGraphForRW(self):
     g1 = ConjunctiveGraph()
     c = CommandLog(Graph2(g1, initNs=INITNS))
     c.addCommand(CMD['c1'], dateTime('18:00:00'), USER['drewp'])
     self.assert_(len(g1) > 0)
Exemple #10
0
 def testUsesSingleGraphForRW(self):
     g1 = ConjunctiveGraph()
     c = CommandLog(Graph2(g1, initNs=INITNS))
     c.addCommand(CMD['c1'], dateTime('18:00:00'), USER['drewp'])
     self.assert_(len(g1) > 0)
Exemple #11
0
 def setUp(self):
     super(WithGraph, self).setUp()
     self.graph = ConjunctiveGraph()
     self.graph.add((CMD['c2'], RDF.type, CMD['Bright']))
     self.cl = CommandLog(Graph2(self.graph, initNs=INITNS))