コード例 #1
0
ファイル: test_darkness.py プロジェクト: umedoblock/umatobi
    def setUp(self):
        darkness_id = 1
        client_id = 1
        start_up_orig = make_start_up_orig()
        dir_name = os.path.join(SIMULATION_DIR,
                                make_start_up_time(start_up_orig))
        log_level = 'INFO'
        nodes_per_darkness = Darkness.NODES_PER_DARKNESS
        first_node_id = 1
        num_darkness = 8
        # share with client and darknesses
        made_nodes = multiprocessing.Value('i', 0)
        # share with client and another darknesses
        leave_there = threading.Event()

        self.darkness_d_config = {
            'id': darkness_id,
            'client_id': client_id,
            'start_up_orig': start_up_orig,
            'dir_name': dir_name,
            'log_level': log_level,
            'num_nodes': nodes_per_darkness,
            'first_node_id': first_node_id,
            'num_darkness': num_darkness,
            # share with client and darknesses
            'made_nodes': made_nodes,
            # share with client and another darknesses
            'leave_there': leave_there,
        }

        self.darkness = Darkness(**self.darkness_d_config)

        for k, v in self.darkness_d_config.items():
            attr = getattr(self.darkness, k)
            self.assertEqual(v, attr)
コード例 #2
0
    def test_make_start_up_orig_with_time_machine(self):
        start_up_orig = lib.make_start_up_orig()
        years_1000 = datetime.timedelta(days=1000*365)

        past = start_up_orig - years_1000
        current = start_up_orig
        future = start_up_orig + years_1000

        with time_machine(past):
            self.assertEqual(lib.make_start_up_orig(), past)

        with time_machine(current):
            self.assertEqual(lib.make_start_up_orig(), current)

        with time_machine(future):
            self.assertEqual(lib.make_start_up_orig(), future)
コード例 #3
0
ファイル: test_logger.py プロジェクト: umedoblock/umatobi
 def setUp(self):
     self.the_moment = lib.make_start_up_orig()
     with time_machine(self.the_moment):
         node_assets = Node.make_node_assets()
     node = Node(host='localhost', id=1, **node_assets)
     key = b'\x01\x23\x45\x67\x89\xab\xcd\xef' * 4
     node.key.update(key)
     self.node = node
     self.key = key
コード例 #4
0
    def setUp(self):
        self.watson_office_addr = ('localhost', 65530)
        simulation_dir = os.path.join(".", SIMULATION_DIR)
        self.log_level = 'INFO'
        self.start_up_orig = lib.make_start_up_orig()
        start_up_time = lib.y15sformat_time(self.start_up_orig)
        dir_name = os.path.join(simulation_dir, start_up_time)
        self.dir_name = dir_name

        td = D_TIMEDELTA.get(self._testMethodName, TD_ZERO)
        self.watson = Watson(self.watson_office_addr, SIMULATION_SECONDS,
                             self.start_up_orig - td, self.dir_name,
                             self.log_level)
コード例 #5
0
    def setUp(self):
        watson_office_addr = ('localhost', 0)
        simulation_seconds = 3
        log_level = 'DEBUG'

        simulation_dir = SIMULATION_DIR
        start_up_orig = lib.make_start_up_orig()
        start_up_time = lib.y15sformat_time(start_up_orig)

        dir_name = os.path.join(simulation_dir, start_up_time)

        if not os.path.isdir(dir_name):
            print(f"os.makedirs(dir_name={dir_name}, exist_ok=True)")
            os.makedirs(dir_name, exist_ok=True)

        self.watson = Watson(watson_office_addr, simulation_seconds,
                             start_up_orig, dir_name, log_level)
コード例 #6
0
    def test_elapsed_time(self):
        td = D_TIMEDELTA.get(self._testMethodName, TD_ZERO)

        start_up_orig = lib.make_start_up_orig()
        et = lib.elapsed_time(start_up_orig - td)
        self.assertEqual(73138, et)
コード例 #7
0
 def test_y15sformat_time(self):
     start_up_orig = lib.make_start_up_orig()
     # Y15S_FORMAT='%Y-%m-%dT%H%M%S'
     y15s = lib.y15sformat_time(start_up_orig)
     self.assertIsInstance(y15s, str)
     self.assertRegex(y15s, r"\A\d{4}-\d{2}-\d{2}T\d{6}\Z")
コード例 #8
0
 def test_make_start_up_orig(self):
     start_up_orig = lib.make_start_up_orig()
     self.assertIsInstance(start_up_orig, datetime.datetime)
コード例 #9
0
 def test_master_hand_path(self):
     start_up_orig = lib.make_start_up_orig()
     start_up_time = lib.make_start_up_time(start_up_orig)
     self.assertEqual(lib.get_master_hand_path(SIMULATION_DIR, start_up_orig), os.path.join(self.tests_simulation_dir, f"{start_up_time}/{MASTER_HAND}"))
コード例 #10
0
 def test_master_hand(self):
     start_up_orig = lib.make_start_up_orig()
     start_up_time = lib.make_start_up_time(start_up_orig)
     self.assertEqual(lib.get_master_hand(start_up_orig), f"{start_up_time}/{MASTER_HAND}")