Esempio n. 1
0
	def test_records_output(self, MockClient, MockOs):
		build_output = ["Line 1", "Line 2"]

		MockClient.return_value.build.return_value = build_output

		instance = DockerInstance(".", "")
		instance.build_image()

		self.assertEqual(instance.build_output ,build_output)
Esempio n. 2
0
	def test_valid_path(self):
		os.path.exists = MagicMock(return_value=True)
		os.path.isdir = MagicMock(return_value=True)
		try:
			instance = DockerInstance(".","")
		except:
			self.fail("Failed eventhough correct path")
Esempio n. 3
0
	def test_correct_parameters(self, MockClient, MockOs):
		instance = DockerInstance(".", "")
		instance.build_image()

		MockClient.assert_called_with(base_url='unix://var/run/docker.sock')
		MockClient.return_value.build.assert_called_with(rm=True,path=instance.path_to_files,tag=instance.tag)
Esempio n. 4
0
	def test_sets_tag(self, MockOs):
		tag = 'test'
		instance = DockerInstance(".", tag)
		self.assertEqual(instance.tag,tag)
Esempio n. 5
0
	def test_docker_file_exists(self):
		with self.assertRaises(DockerFileNotFoundError):
			instance = DockerInstance(".","")
Esempio n. 6
0
	def test_path_not_directory(self):
		with self.assertRaises(ValueError):
			instance = DockerInstance("/home/deploy/demokratikollen/deployment/tests/test_generic_docker_instance.py","")
Esempio n. 7
0
	def test_invalid_path(self):
		with self.assertRaises(FileNotFoundError):
			instance = DockerInstance("invalidpath","")