~free.ekanayaka/landscape-client/lucid-1.5.0-0ubuntu0.10.04.0

« back to all changes in this revision

Viewing changes to landscape/manager/tests/test_customgraph.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-10-09 18:21:24 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20091009182124-8n1x5tfa8r0kxd5n
Tags: 1.3.2.4-0ubuntu0.9.10.0
* New upstream release:
  - Catch import errors in the landscape-sysinfo script to prevent
    errors when landscape-sysinfo is run to update the motd during
    upgrade (LP: #349996)
  - Fix a long-standing bug in the client which causes resynchronisations
    on the server (LP: #144475)
  - When downloading hash-id stores, pass possible custom SSL certificates
    to the fetch fuction (LP: #435887)
  - Handle unicode username in custom graphs, and also report missing user
    to the server properly (LP: #406388)
  - Handle a SQlite bug when creating package store database, by making an
    extra query to flush the table cache (LP: #416629)

Show diffs side-by-side

added added

removed removed

Lines of Context:
360
360
                      {"error":
361
361
                       u"ProhibitedUserError: Custom graph cannot be run as "
362
362
                        "user %s" % (username,),
363
 
                       "script-hash": "9893532233caff98cd083a116b013c0b",
 
363
                       "script-hash": "",
364
364
                       "values": []}},
365
365
                  "type": "custom-graph"}])
366
366
 
388
388
                self.broker_service.message_store.get_pending_messages(),
389
389
                [{"data": {123:
390
390
                      {"error": u"UnknownUserError: Unknown user 'foo'",
391
 
                       "script-hash": "9893532233caff98cd083a116b013c0b",
 
391
                       "script-hash": "",
392
392
                       "values": []}},
393
393
                  "type": "custom-graph"}])
394
394
 
426
426
    def test_run_removed_file(self):
427
427
        """
428
428
        If run is called on a script file that has been removed, it doesn't try
429
 
        to run it, and remove the graph from the store.
 
429
        to run it, but report it with an empty hash value.
430
430
        """
431
431
        self.store.add_graph(123, "/nonexistent", None)
432
432
        factory = StubProcessFactory()
438
438
        self.graph_manager.exchange()
439
439
        self.assertMessages(
440
440
            self.broker_service.message_store.get_pending_messages(),
441
 
            [{"data": {},
 
441
            [{"data": {123: {"error": u"", "script-hash": "", "values": []}},
442
442
              "type": "custom-graph"}])
443
 
        self.assertIdentical(self.store.get_graph(123), None)
444
443
 
445
444
    def test_send_message_add_stored_graph(self):
446
445
        """
466
465
              "timestamp": 0,
467
466
              "type": "custom-graph"}])
468
467
 
469
 
    def test_send_message_remove_not_present_graph(self):
470
 
        """
471
 
        C{send_message} checks the presence of the custom-graph script, and
472
 
        remove the graph if the file is not present anymore.
473
 
        """
 
468
    def test_send_message_check_not_present_graph(self):
 
469
        """C{send_message} checks the presence of the custom-graph script."""
474
470
        uid = os.getuid()
475
471
        info = pwd.getpwuid(uid)
476
472
        username = info.pw_name
489
485
              "data": {},
490
486
              "timestamp": 0,
491
487
              "type": "custom-graph"}])
492
 
        self.assertIdentical(self.store.get_graph(123), None)
493
488
 
494
489
    def test_send_message_dont_rehash(self):
495
490
        """
596
591
                self.broker_service.message_store.get_pending_messages(),
597
592
                [{"api": API,
598
593
                  "data": {123: {"error": u"",
599
 
                                 "script-hash": "991e15a81929c79fe1d243b2afd99c62",
 
594
                                 "script-hash":
 
595
                                    "991e15a81929c79fe1d243b2afd99c62",
600
596
                                 "values": []}},
601
597
                  "timestamp": 0,
602
598
                  "type": "custom-graph"}])
679
675
        self.assertEquals(len(factory.spawns), 0)
680
676
 
681
677
        return result.addCallback(self.assertEquals, [])
 
678
 
 
679
    def test_run_unknown_user_with_unicode(self):
 
680
        """
 
681
        Using a non-existent user containing unicode characters fails with the
 
682
        appropriate error message.
 
683
        """
 
684
        username = u"non-existent-f\N{LATIN SMALL LETTER E WITH ACUTE}e"
 
685
 
 
686
        self.manager.config.script_users = "ALL"
 
687
 
 
688
        filename = self.makeFile("some content")
 
689
        self.store.add_graph(123, filename, username)
 
690
        factory = StubProcessFactory()
 
691
        self.graph_manager.process_factory = factory
 
692
        result = self.graph_manager.run()
 
693
 
 
694
        self.assertEquals(len(factory.spawns), 0)
 
695
 
 
696
        def check(ignore):
 
697
            self.graph_manager.exchange()
 
698
            self.assertMessages(
 
699
                self.broker_service.message_store.get_pending_messages(),
 
700
                [{"data": {123:
 
701
                      {"error":
 
702
                           u"UnknownUserError: Unknown user '%s'" % username,
 
703
                       "script-hash": "9893532233caff98cd083a116b013c0b",
 
704
                       "values": []}},
 
705
                  "type": "custom-graph"}])
 
706
 
 
707
        return result.addCallback(check)