fix: replace deprecated UTC with timezone.utc in test files
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
- Update datetime.now(UTC) to datetime.now(timezone.utc) across all test files - Fix test_block_import.py to use dynamic base height from current chain head - Fix test_block_import_complete.py to calculate base_height from current head - Add SSH options for non-interactive connection in test_cross_node_blockchain.py - Add timeout parameter to SSH subprocess call - Update all timestamp generation to use timezone.utc
This commit is contained in:
@@ -23,7 +23,7 @@ class MockDecisionEngine:
|
||||
'decision_id': decision_id,
|
||||
'status': 'completed',
|
||||
'result': decision_data.get('proposal', 'approved'),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
async def submit_vote(self, vote_data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
@@ -32,7 +32,7 @@ class MockDecisionEngine:
|
||||
return {
|
||||
'vote_id': vote_id,
|
||||
'status': 'recorded',
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
class MockConsensusAlgorithm:
|
||||
@@ -50,7 +50,7 @@ class MockConsensusAlgorithm:
|
||||
'consensus_id': consensus_id,
|
||||
'status': 'consensus_reached',
|
||||
'agreement': True,
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
class TestDecisionEngine:
|
||||
@@ -102,7 +102,7 @@ class TestDecisionEngine:
|
||||
'amounts': {'cpu': 50, 'memory': 2048, 'storage': 100}
|
||||
},
|
||||
'participants': ['agent_001', 'agent_002', 'agent_003'],
|
||||
'deadline': (datetime.now(UTC) + timedelta(hours=1)).isoformat()
|
||||
'deadline': (datetime.now(timezone.utc) + timedelta(hours=1)).isoformat()
|
||||
}
|
||||
|
||||
result = await self.decision_engine.make_decision(decision_data)
|
||||
@@ -157,7 +157,7 @@ class TestConsensusAlgorithm:
|
||||
{'rule': 'priority_based', 'weight': 0.6},
|
||||
{'rule': 'fair_share', 'weight': 0.4}
|
||||
],
|
||||
'effective_date': datetime.now(UTC).isoformat()
|
||||
'effective_date': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ class TestAgentLifecycleManagement:
|
||||
'agent_id': 'agent_001',
|
||||
'capabilities': ['decision_making', 'voting'],
|
||||
'status': 'active',
|
||||
'join_time': datetime.now(UTC).isoformat()
|
||||
'join_time': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
self.agents[agent_data['agent_id']] = agent_data
|
||||
@@ -276,12 +276,12 @@ class TestAgentLifecycleManagement:
|
||||
self.agents[agent_id] = {
|
||||
'agent_id': agent_id,
|
||||
'status': 'active',
|
||||
'last_update': datetime.now(UTC).isoformat()
|
||||
'last_update': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
# Update agent status
|
||||
self.agents[agent_id]['status'] = 'busy'
|
||||
self.agents[agent_id]['last_update'] = datetime.now(UTC).isoformat()
|
||||
self.agents[agent_id]['last_update'] = datetime.now(timezone.utc).isoformat()
|
||||
|
||||
assert self.agents[agent_id]['status'] == 'busy'
|
||||
assert 'last_update' in self.agents[agent_id]
|
||||
|
||||
@@ -27,7 +27,7 @@ class MockAutonomousEngine:
|
||||
'action': self._determine_action(context),
|
||||
'reasoning': self._generate_reasoning(context),
|
||||
'confidence': self._calculate_confidence(context),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
self.decisions.append(decision)
|
||||
return decision
|
||||
@@ -67,7 +67,7 @@ class MockLearningSystem:
|
||||
'experience': experience,
|
||||
'lessons_learned': self._extract_lessons(experience),
|
||||
'performance_impact': self._calculate_impact(experience),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
self.experience_buffer.append(learning_data)
|
||||
return learning_data
|
||||
@@ -93,7 +93,7 @@ class MockLearningSystem:
|
||||
'type': adaptation_data.get('type', 'parameter_adjustment'),
|
||||
'changes': adaptation_data.get('changes', {}),
|
||||
'expected_improvement': adaptation_data.get('expected_improvement', 0.1),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
self.adaptations[adaptation_id] = adaptation
|
||||
return adaptation
|
||||
@@ -128,7 +128,7 @@ class MockPolicyEngine:
|
||||
'compliance_score': compliance_score,
|
||||
'violations': violations,
|
||||
'approved': compliance_score >= 0.8 and len(violations) == 0,
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
def _calculate_compliance(self, decision: Dict[str, Any]) -> float:
|
||||
|
||||
@@ -26,7 +26,7 @@ class MockVisionProcessor:
|
||||
'processing_type': processing_type,
|
||||
'size': len(image_data),
|
||||
'format': 'processed',
|
||||
'timestamp': datetime.now(UTC).isoformat(),
|
||||
'timestamp': datetime.now(timezone.utc).isoformat(),
|
||||
'analysis': await self._analyze_image(image_data, processing_type)
|
||||
}
|
||||
self.processed_images[image_id] = result
|
||||
@@ -130,7 +130,7 @@ class MockMultiModalAgent:
|
||||
'result_id': result_id,
|
||||
'modalities_processed': list(results.keys()),
|
||||
'integration': await self._integrate_modalities(results),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
self.integrated_results[result_id] = integrated_result
|
||||
@@ -151,7 +151,7 @@ class MockMultiModalAgent:
|
||||
return {
|
||||
'sensor_type': sensor_data.get('type', 'unknown'),
|
||||
'readings': sensor_data.get('readings', {}),
|
||||
'timestamp': sensor_data.get('timestamp', datetime.now(UTC).isoformat()),
|
||||
'timestamp': sensor_data.get('timestamp', datetime.now(timezone.utc).isoformat()),
|
||||
'quality': 'good'
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class MockContextIntegration:
|
||||
'vision_result': vision_result,
|
||||
'context_data': context_data,
|
||||
'enhanced_understanding': await self._enhance_understanding(vision_result, context_data),
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
self.context_history.append(integration)
|
||||
@@ -298,7 +298,7 @@ class TestMultiModalIntegration:
|
||||
self.sample_sensor_data = {
|
||||
'type': 'temperature',
|
||||
'readings': {'value': 25.5, 'unit': 'celsius'},
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -431,7 +431,7 @@ class TestContextIntegration:
|
||||
vision_result = await self.vision_processor.process_image(self.sample_image)
|
||||
context_data = {
|
||||
'location': f'location_{i}',
|
||||
'timestamp': datetime.now(UTC).isoformat()
|
||||
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||
}
|
||||
await self.context_integration.integrate_context(vision_result, context_data)
|
||||
|
||||
@@ -530,11 +530,11 @@ class TestPerformanceMetrics:
|
||||
@pytest.mark.asyncio
|
||||
async def test_processing_speed(self):
|
||||
"""Test image processing speed"""
|
||||
start_time = datetime.now(UTC)
|
||||
start_time = datetime.now(timezone.utc)
|
||||
|
||||
result = await self.vision_processor.process_image(self.sample_image)
|
||||
|
||||
end_time = datetime.now(UTC)
|
||||
end_time = datetime.now(timezone.utc)
|
||||
processing_time = (end_time - start_time).total_seconds()
|
||||
|
||||
assert processing_time < 2.0 # Should process within 2 seconds
|
||||
@@ -545,12 +545,12 @@ class TestPerformanceMetrics:
|
||||
"""Test batch image processing"""
|
||||
images = [self.sample_image] * 5
|
||||
|
||||
start_time = datetime.now(UTC)
|
||||
start_time = datetime.now(timezone.utc)
|
||||
results = []
|
||||
for image in images:
|
||||
result = await self.vision_processor.process_image(image)
|
||||
results.append(result)
|
||||
end_time = datetime.now(UTC)
|
||||
end_time = datetime.now(timezone.utc)
|
||||
|
||||
total_time = (end_time - start_time).total_seconds()
|
||||
avg_time = total_time / len(images)
|
||||
@@ -625,9 +625,9 @@ class TestVisionIntegration:
|
||||
# Simulate real-time processing
|
||||
processing_times = []
|
||||
for i in range(10):
|
||||
start_time = datetime.now(UTC)
|
||||
start_time = datetime.now(timezone.utc)
|
||||
await vision_processor.process_image(f'frame_{i}'.encode())
|
||||
end_time = datetime.now(UTC)
|
||||
end_time = datetime.now(timezone.utc)
|
||||
processing_times.append((end_time - start_time).total_seconds())
|
||||
|
||||
avg_time = sum(processing_times) / len(processing_times)
|
||||
|
||||
Reference in New Issue
Block a user