def test_empty_bucket(self): with hlp.captured_output() as (out, err): self.s.empty_bucket('bucket') self.assertEqual(out.getvalue().strip(), "Deleting all objects of bucket") with hlp.captured_output() as (out, err): self.s.empty_bucket(1) self.assertEqual(out.getvalue().strip(), "The bucket named 1 not exists")
def test_empty_domain(self): with hlp.captured_output() as (out, err): self.s.empty_domain('id') self.assertEqual( out.getvalue().strip(), "Deleting all objects of id\nDeleting user profile named user\nDeleting app named default\nDeleting app named datascience" ) with hlp.captured_output() as (out, err): self.s.empty_domain(1) self.assertEqual(out.getvalue().strip(), "The domain 1 not exists")
def test_run(self): with hlp.captured_output() as (out, err): with self.assertRaises(NotImplementedError): self.s.run({}) output = out.getvalue().strip() self.assertEqual(output, "['service']\nRunning AWS saving on SERVICE service")
def test_empty_buckets(self): with hlp.captured_output() as (out, err): self.s.empty_buckets(self.s.stack.resources) self.assertEqual( out.getvalue().strip(), "Deleting all objects of aurora\nDeleting all objects of bucket\nDeleting all objects of ec2" )
def test_already_exists(self): self.s.sagemaker.set_not_exists_simulation(False) self.assertTrue(self.s.already_exists('id')) self.s.sagemaker.set_not_exists_simulation(True) with hlp.captured_output() as (out, err): self.assertFalse(self.s.already_exists('domain-id')) self.assertEqual(out.getvalue().strip(), "The domain domain-id not exists")
def test_already_exists(self): self.s.s3.set_not_exists_simulation(False) self.assertTrue(self.s.already_exists('bucket-name')) self.s.s3.set_not_exists_simulation(True) with hlp.captured_output() as (out, err): self.assertFalse(self.s.already_exists('bucket-name')) self.assertEqual(out.getvalue().strip(), "The bucket named bucket-name not exists")
def test_already_exists(self): self.s.ecr.set_not_exists_simulation(False) self.assertTrue(self.s.already_exists('mlops-studio-processing')) self.s.ecr.set_not_exists_simulation(True) with hlp.captured_output() as (out, err): self.assertFalse(self.s.already_exists('mlops-studio-processing')) self.assertEqual( out.getvalue().strip(), "The repository named mlops-studio-processing not exists")
def test_empty_user_profile(self): with hlp.captured_output() as (out, err): self.s.empty_user_profile('user|id') self.assertEqual( out.getvalue().strip(), "Deleting all objects of user|id\nDeleting app named datascience") with hlp.captured_output() as (out, err): self.s.empty_user_profile('user|id', False) self.assertEqual( out.getvalue().strip(), "Deleting all objects of user|id\nDeleting app named datascience") with hlp.captured_output() as (out, err): self.s.empty_user_profile('user|id', True) self.assertEqual( out.getvalue().strip(), "Deleting all objects of user|id\nDeleting app named default\nDeleting app named datascience" ) with self.assertRaises(ValueError): self.s.empty_user_profile('user')
def test_should_not_start_without_eth_from_argument( self, deployment: Deployment): # when with captured_output() as (out, err): with pytest.raises(SystemExit): ArbitrageKeeper(args=args(f""), web3=deployment.web3) # then assert "error: the following arguments are required: --eth-from" in err.getvalue( )
def test_empty_sagemaker_user_profile(self): with hlp.captured_output() as (out, err): self.s.empty_sagemaker_user_profile(['sagemaker-user-profile-id']) self.assertEqual( out.getvalue().strip(), "Deleting all resources of sagemaker-user-profile-id except JupyterServer" ) with hlp.captured_output() as (out, err): self.s.empty_sagemaker_user_profile(['sagemaker-user-profile-id'], False) self.assertEqual( out.getvalue().strip(), "Deleting all resources of sagemaker-user-profile-id except JupyterServer" ) with hlp.captured_output() as (out, err): self.s.empty_sagemaker_user_profile(['sagemaker-user-profile-id'], True) self.assertEqual( out.getvalue().strip(), "Deleting all resources of sagemaker-user-profile-id")
def test_should_not_start_without_tub_address_argument( self, deployment: Deployment): # when with captured_output() as (out, err): with pytest.raises(SystemExit): BiteKeeper(args=args( f"--eth-from {deployment.web3.eth.defaultAccount}"), web3=deployment.web3) # then assert "error: the following arguments are required: --tub-address" in err.getvalue( )
def test_should_not_start_without_tap_address_argument( self, deployment: Deployment): # when with captured_output() as (out, err): with pytest.raises(SystemExit): ArbitrageKeeper(args=args( f"--eth-from {deployment.our_address.address}" f" --tub-address {deployment.tub.address}"), web3=deployment.web3) # then assert "error: the following arguments are required: --tap-address" in err.getvalue( )
def test_should_not_start_without_top_up_margin_argument( self, deployment: Deployment): # when with captured_output() as (out, err): with pytest.raises(SystemExit): CdpKeeper(args=args( f"--eth-from {deployment.web3.eth.defaultAccount} " f"--tub-address {deployment.tub.address} " f"--min-margin 0.2"), web3=deployment.web3) # then assert "error: the following arguments are required: --top-up-margin" in err.getvalue( )
def test_should_not_start_without_max_engagement_argument( self, deployment: Deployment): # when with captured_output() as (out, err): with pytest.raises(SystemExit): ArbitrageKeeper(args=args( f"--eth-from {deployment.our_address.address}" f" --tub-address {deployment.tub.address}" f" --tap-address {deployment.tap.address}" f" --oasis-address {deployment.otc.address}" f" --base-token {deployment.sai.address}" f" --min-profit 1.0"), web3=deployment.web3) # then assert "error: the following arguments are required: --max-engagement" in err.getvalue( )
def get_output(self, event={}): with hlp.captured_output() as (out, err): self.s.run(event) return out.getvalue().strip()
def test_empty_buckets(self): with hlp.captured_output() as (out, err): self.s.empty_buckets(['bucket']) self.assertEqual(out.getvalue().strip(), "Deleting all resources of bucket")
def test_empty_sagemaker_domains(self): with hlp.captured_output() as (out, err): self.s.empty_sagemaker_domains(['sagemaker-domain-id']) self.assertEqual(out.getvalue().strip(), "Deleting all resources of sagemaker-domain-id")
def test_print_service_log(self): with hlp.captured_output() as (out, err): self.s.print_service_log("service") output = out.getvalue().strip() self.assertEqual(output, "Running AWS saving on SERVICE service")
def test_stop_apps(self): with hlp.captured_output() as (out, err): self.s.stop_apps('id') self.assertEqual( out.getvalue().strip(), "Deleting all objects of user\nDeleting app named datascience")