def test_create_remote_repo_raises(self): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(NotImplementedError): server.create_remote_repo("")
def test_get_server_repo_list_raises(self): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(NotImplementedError): server.get_server_repo_list()
def test_module_path_calls_dev_area(self, area_path_mock, join_mock): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.dev_module_path("test_module") join_mock.assert_called_once_with(area_path_mock.return_value, "test_module")
def test_given_invalid_source_then_clone_not_called( self, mock_clone_from, _2, _3): source = "/does/not/exist" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.clone_multi(source) self.assertFalse(mock_clone_from.call_count)
def test_given_invalid_source_then_error_raised(self, mock_clone_from, mock_is_server_repo): source = "does/not/exist" module = "test_module" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(ValueError): server.clone(source, module)
def test_given_existing_module_name_then_error_raised( self, mock_clone_from, mock_is_server_repo, mock_isdir): source = "test/source" module = "already_exists" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(ValueError): server.clone(source, module)
def test_given_valid_module_name_then_clone(self, mock_clone_from, _1, _2, _3): source = "controls/area/" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.clone_multi(source) mock_clone_from.assert_called_once_with( "[email protected]/controls/area/test_module", "./test_module")
def test_given_ioc_area_name_then_clone_with_domain_in_file_name( self, mock_clone_from, _1, _2, _3): source = "controls/ioc/" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.clone_multi(source) mock_clone_from.assert_called_once_with( "[email protected]/controls/ioc/BL/module", "./BL/module")
def test_given_invalid_source_then_error_raised(self, mock_clone_from, mock_is_server_repo, mock_mkdtemp): source = "/does/not/exist" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(ValueError): server.temp_clone(source) self.assertFalse(mock_clone_from.call_count)
def test_given_one_existing_module_one_not_then_clone_one( self, mock_clone_from, _1, _2, _3, _4): source = "controls/area" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.clone_multi(source) mock_clone_from.assert_called_once_with( "[email protected]/controls/ioc/domain/test_module", "./test_module2")
def test_given_repo_with_domain_code_then_tempdir_arg_has_forwardslash_removed( self, mock_clone_from, _1, _2, _3, mock_mkdtemp): source = "controls/ioc/domain/test_module" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.temp_clone(source) mock_mkdtemp.assert_called_once_with(suffix="_domain_test_module") mock_clone_from.assert_called_once_with( "[email protected]/controls/ioc/domain/test_module", "tempdir")
def test_given_valid_inputs_then_clone_from_called(self, mock_clone_from, _1, is_server_repo_mock, _2, _3): source = "test/source/test_module" module = "test_module" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") server.clone(source, module) is_server_repo_mock.assert_called_once_with("test/source/test_module") mock_clone_from.assert_called_once_with( "[email protected]/test/source", "./test_module", origin='gitlab')
def test_given_valid_inputs_then_clone_from_called(self, mock_clone_from, _1, _2, _3, mock_mkdtemp): source = "controls/area/test_module" server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") # Do a shallow clone server.temp_clone(source, depth=1) mock_clone_from.assert_called_once_with( "[email protected]/controls/area/test_module", "tempdir", depth=1) mock_mkdtemp.assert_called_once_with(suffix="_test_module") # Reset mocks mock_clone_from.reset_mock() mock_mkdtemp.reset_mock() # Do a normal clone server.temp_clone(source) mock_clone_from.assert_called_once_with( "[email protected]/controls/area/test_module", "tempdir") mock_mkdtemp.assert_called_once_with(suffix="_test_module")
def test_given_path_exists_then_return_true(self, _): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") self.assertTrue(server.is_server_repo("controls/test/path"))
def test_area_path_raises(self): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") with self.assertRaises(NotImplementedError): server.dev_area_path()
def test_given_path_does_not_exist_then_return_false(self, _): server = GitServer("*****@*****.**", "*****@*****.**", "*****@*****.**") self.assertFalse(server.is_server_repo("controls/test/not_a_path"))
def test_get_clone_path_raises(self): with self.assertRaises(NotImplementedError): GitServer.get_clone_path("")