コード例 #1
0
ファイル: inboxer_test.py プロジェクト: djeremiah/bakula
    def test_add_file_by_bytes(self):
        master_inbox_path = os.path.join(self.TEST_DIR, "master_inbox")
        container_inboxes_path = os.path.join(self.TEST_DIR, "container_inboxes")

        # Initialize inboxer using a tmp directory for unit testing
        inboxer = Inboxer(master_inbox_path, container_inboxes_path)

        counter = inboxer.add_file_by_bytes("MyTopic",
                                            "This is a test file weeee")
        master_inbox_destination = os.path.join(master_inbox_path,
                                                "MyTopic",
                                                str(counter))
        self.assertEqual(os.path.exists(master_inbox_destination), True)
コード例 #2
0
ファイル: orchestrator_test.py プロジェクト: djeremiah/bakula
    def test_Orchestrator_with_threshold(self):
        Registration.create(
            topic="MyTopic1",
            container="busybox",
            creator="me",
            threshold=1,
            timeout=15
        )

        inboxer = Inboxer(os.path.join(self.TEST_DIR, "master_inbox"),
                          os.path.join(self.TEST_DIR, "container_inboxes"))
        orchestrator = Orchestrator(inboxer)
        inboxer.add_file_by_bytes("MyTopic1", "This is some data")
        self.assertEqual(len(inboxer.get_inbox_list("MyTopic1")), 0)
コード例 #3
0
    def test_on(self):
        def callback(data):
            self.assertEqual(data["topic"], "MyTopicEvent")

        master_inbox_path = os.path.join(self.TEST_DIR, "master_inbox")
        container_inboxes_path = os.path.join(self.TEST_DIR, "container_inboxes")
        testfile = os.path.join(self.TEST_DIR, "testFile.json")

        # Initialize inboxer using a tmp directory for unit testing
        inboxer = Inboxer(master_inbox_path, container_inboxes_path)

        inboxer.on("received", callback)
        # Create our test file
        with open(testfile, "a"):
            os.utime(testfile, None)

        counter = inboxer.add_file_by_path("MyTopicEvent", testfile)
コード例 #4
0
    def test_add_file_by_path(self):
        master_inbox_path = os.path.join(self.TEST_DIR, "master_inbox")
        container_inboxes_path = os.path.join(self.TEST_DIR, "container_inboxes")
        testfile = os.path.join(self.TEST_DIR, "testFile.json")

        # Initialize inboxer using a tmp directory for unit testing
        inboxer = Inboxer(master_inbox_path, container_inboxes_path)

        # Create our test file
        with open(testfile, "a"):
            os.utime(testfile, None)

        counter = inboxer.add_file_by_path("MyTopic", testfile)
        master_inbox_destination = os.path.join(master_inbox_path,
                                                "MyTopic",
                                                str(counter))
        self.assertEqual(os.path.exists(testfile), False)
        self.assertEqual(os.path.exists(master_inbox_destination), True)
コード例 #5
0
ファイル: inboxer_test.py プロジェクト: djeremiah/bakula
    def test_get_inbox_list(self):
        master_inbox_path = os.path.join(self.TEST_DIR, "master_inbox")
        container_inboxes_path = os.path.join(self.TEST_DIR, "container_inboxes")
        testfile1 = os.path.join(self.TEST_DIR, "testFile1.json")
        testfile2 = os.path.join(self.TEST_DIR, "testFile2.json")
        testfile3 = os.path.join(self.TEST_DIR, "testFile3.json")

        # Initialize inboxer using a tmp directory for unit testing
        inboxer = Inboxer(master_inbox_path, container_inboxes_path)

        # Create our test files
        with open(testfile1, "a"):
            os.utime(testfile1, None)

        with open(testfile2, "a"):
            os.utime(testfile2, None)

        with open(testfile3, "a"):
            os.utime(testfile3, None)

        inboxer.add_file_by_path("MyTopic", testfile1)
        inboxer.add_file_by_path("MyTopic", testfile2)
        inboxer.add_file_by_path("MyTopic", testfile3)

        self.assertEqual(len(inboxer.get_inbox_list("MyTopic")), 3)